Since I upgraded to the newest Selenium version my Firefox driver is not working properly. Failing to find an answer from searching Google/Stack I hope someone here has an answer.
I've build a page object model for logging in to a webpage, clicking the admin-site and filling in username/password + submitting. This code was written for Selenium 2.53.6 but still works for IE and Chrome. The part that is failing for me is this line of code:
driver.find_element_by_xpath(locators["login.open"]).click()
The locator is:
locators["login.open"] = "//*[@href='//www.phptravels.net/admin']"
Since it is working in IE and Chrome then it puzzles me that Firefox can not .click()
anymore?
I'm not getting an error message in my console, it just doesn't click the admin-site button. Could this be related to a given Firefox version for Selenium 3/geckodriver?
All drivers are up to date using pip
I am using this site for practicing my Selenium: http://phptravels.com/demo/
Edit (1): I've tried with Firefox version 48 and 49 - still not working
Edit (2): geckodriver is configured with Firefox binaries declared however the driver is still not performing the .click()
from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
binary = FirefoxBinary('path/to/binary')
driver = webdriver.Firefox(firefox_binary=binary)
Edit (3): I check if the element is present by the xpath locator using is_displayed() and it returns True
. So I know that it can find the element.
Edit (4): 1) Tried with the Nightly build as suggested, not working. 2) Tried with find_element_by_link_text, also not working. 3) Tried various versions of geckodriver (10.0, 11.0, 11.1 for 32 and 64 bit on all versions)
Edit (5): "Plugin Container for Firefox has stopped working" spawns consistently every time a test case fails.
Edit (6): Possible solution to the problem: I did another test on a different website, and Firefox successfully performs a .click(). On the first target webpage where .click() fails is a huge javascript that runs when you open the page. This could possibly mess up with the geckodriver's ability to do .click() on javascript-heavy pages.
Edit (7): Using .send_keys(Keys.RETURN) with the Keys library works, but might require additional reconfiguration if you're using POM. Explicitly doing some time.sleep will get you around, but for now it's still brittle to use Selenium 3 + Firefox/geckodriver for web browser automation. Downgrade to last stable version (2.53.6) if you need to test Firefox (note: newest versions of Firefox wont work).