3

I will try to be as clear as possible. Lets take an identical test case in both browsers. Open a page and find an element by the following method:

wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Logout"))).click(); 

Absolutely identical cases and it works fine in Chrome but in Firefox it doesn't find the element. I'm using:

Selenium 3.4
GeckoDriver 0.16 
Firefox 53.0

P.S After sometime i found out that the only difference is that thous elements that are located in and which i want to find by text aren't reachable. Even though it works perfectly with Chrome. Is there any way to deal with this or i have to make a totally new class and take another approach?

1
  • You can do this using native javascript, using the execute script in Selenium Commented Apr 30, 2017 at 17:54

2 Answers 2

1

Most reliable way to locate element is by ID or name, or possibly CSS locator. Locating using other element attributes is less reliable.

Least reliable is the one method you can find most often in questions (so you can guess that is most error-prone) - by XPath.

Think how this functionality is implemented. WebDriver implementation has to have a own mirror copy of browser's DOM, and manipulate own copy to keep it in sync with the browser's copy. And both versions will use caching and other optimizations for performance. Many things can go wrong in such situation, it is amazing it is working as reliably as it is.

0

You will find this a lot between different browsers.
Investigate with manual delays and simple find element to start narrowing down the problem.
You may need to adjust the test code in order for it to be passable in different browsers.

1
  • This is a good and reasonable answer i agree but still, in basic theory it can't click nor find an element despite the fact that it is clickable, does it mean there is a problem with the GeckoDriver? I even used the following method: presenceOfElementLocated before waiting for it to be clickable and still no result.
    – R.Ro
    Commented Apr 30, 2017 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.