Issue
I have a Django view function:
def bypass_link(request, pk=None):
instance = fields.objects.get(pk=pk)
link = instance.quote
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(ChromeDriverManager().install(), options=options)
driver.get(link)
driver.find_element_by_id("butAgree").click()
return redirect(link)
template:
<td data-label="Quote">
<a href="{% url 'bypass_link' i.id %}" target="_blank">{{ i.link }}</a>
</td>
urls.py
from django.conf.urls import url
url(r'^bypass_link/(?P<pk>\d+)/$', views.bypass_link, name="bypass_link"),
This opens two links when I click on the hyperlink. When I remove the return redirect(link)
, this shows the error on the page but the selenium window is working fine.
I just want to open the selenium window when clicking on the hyperlink.
Edits:
I changed the line to return redirect(index)
, this worked on local. But when I tried this on production, this shows an error. This error was solved if I run selenium in headless mode. But, I don't want to run in headless mode in production. Is it true that Selenium works only in headless mode in production?
Solution
Headless software (e.g. "headless Java" or "headless Linux",) is software capable of working on a device without a graphical user interface. ... The term "headless" is most often used when the ordinary version of the program requires that a graphics card or similar graphical interface device be present.
https://en.wikipedia.org/wiki/Headless_software
If by "production" you mean a remote server like a VPS or something, Then probably no you can not run a graphical web browser on the server it would have to be headless.
Answered By - Reed Jones
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.