I have the links to the admin area of my website: it is possible to launch those URIs (links) with selenium (in a given browser) without needing to authenticate previously ? If not, then how could I deal with authentication using selenium ?
-
1Selenium doesn't deal with authentication too well. This might be useful for some alternative workarounds: stackoverflow.com/questions/3021602/…Luke Peterson– Luke Peterson2014-06-28 07:26:23 +00:00Commented Jun 28, 2014 at 7:26
-
What sort of authentication?SiKing– SiKing2014-06-30 17:13:15 +00:00Commented Jun 30, 2014 at 17:13
-
why to downvote ? :) It is resolved 4 months ago :)user3522371– user35223712014-10-29 10:28:43 +00:00Commented Oct 29, 2014 at 10:28
Add a comment
|
1 Answer
Not sure what you mean but you can just use selectors and enter credentials to the authentication fields. i.e.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get(url)
driver.find_element_by_id("IDOFLOGIN").sendKeys("YOUR LOGIN")
driver.find_element_by_id("PASSOFLOGIN").sendKeys("YOUR PASSWORD")
driver.find_element_by_id("login button").click()
# Continue
you can find element not necessarily by ID you can also you class, xpath and so on.
1 Comment
Scruffy Paws
Thanks, this helped me. In my case, though, I needed to add
from selenium.webdriver.common.keys import Keys after the first line and then change sendKeys to send_keys