An url is launched correctly through selenium IDE , but not through script
The type of error you are observing seems to me arising from the mismatch between Selenium
, geckodriver
and Firefox
versions.
As per the Release Notes Selenium v3.6.0
should go well with geckodriver v.0.18.0
(where as geckodriver v.0.19.0
is recommended).
But geckodriver v.0.18.0
Release Notes clearly mentions the following:
geckodriver now recommends Firefox 53 and greater geckodriver compatible with Firefox 56 and greater
So upgrading your Firefox
to v53+
level will definitely solve your issue.
Update:
Based on your comment you can change the locator for username
field to either of the following:
css_selector
driver.find_element_by_css_selector("input[name=username]")
xpath
driver.find_element_by_xpath("//input[@name='username']")
Chances are your driver is trying to grab the username field after the first load, fails with an exception and shuts it down before the redirect. It needs to wait. You could try:
from selenium.webdriver.support import expected_conditions as ECfrom selenium.webdriver.support.ui import WebDriverWait...def test_worked2(self): driver = self.driver driver.get(base_url) WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.NAME, 'username'))).send_keys("xxx")
i was able to resolve this issue by using Firefox profile, i don't know what difference it made, but it actually worked.
Link to create Firefox profile
http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
Below is the code
from selenium import webdriverfp = webdriver.FirefoxProfile('C:/Users/<user name>/AppData/Roaming/Mozilla/Firefox/Profiles/abc3defghij2.ProfileName')driver = webdriver.Firefox(fp)driver.get("https://www.example.com/membersarea")