I have a Selenium Java based automation infrastructure. Most elements locators are using XPath
since our web site uses several templates where elements can be located based on their texts only.
It is working just perfect on Chrome however it doesn't work on Firefox.
The most basic action - element.click()
doesn't work with Selenium on Firefox while it works perfect on Chrome!
There is no exceptions thrown, just nothing done.
I do not use any kind of very complex xPath
expression, mostly something like //*[contains(text(),'Some unique text')]
that gives a clear unique element locator and each click()
is performed after getting the element visible with methods like this:
public void clickVisible(String xpath){
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
driver.findElement(By.xpath(xpath)).click();
}
While running and debugging the tests I saw that elements are found visible shortly while running on Firefox too, however click()
simply doesn't work there.
In case I locate those elements with css selector
it works on Firefox perfect!
I already heard that xPath
engines are different in each browser and I saw several old posts here dealing with xPath
related problems, but mostly with IE, not with Firefox, and most of that posts are written many years ago.
Also, I worked with Firefox several years ago and there were no such problems that time!
I'm trying to understand what happened with Selenium on Firefox so it is not performing very basic commands for xPath
located elements?
I couldn't find any clear documentation / explanation about this.
This post looks interesting, however I couldn't try setting capability.setCapability("marionette", false);
since my Firefox options are set in the following manner:
FirefoxProfile profile = new FirefoxProfile();
FirefoxOptions options = new FirefoxOptions();
profile.setPreference("browser.download.dir",downloadsPath);
--------
options.setProfile(profile);
driver = new FirefoxDriver(options);