D
D
densaface2015-11-03 11:38:32
Java
densaface, 2015-11-03 11:38:32

Why doesn't selenium find a specific locator on the page?

For more than half a year, I slowly struggled with the bug described below in my tests and could not even come up with some rational explanation for what was happening.
So, tests are performed in fully automatic mode on 2 machines, a client and a selenium server, in which some content is loaded in the browser, web interface elements are searched by locators, web buttons, checkboxes, etc. are pressed.
The problem is reproduced somewhere in every fifth case at least , in a certain place of a certain test case there is no element by the locator, but rather the delete button the
exact name of the locator:
//div[@class="listActionItem" and text()='delete']
And in 3 different ways I made sure that such a button is present:
1 Visually in the screenshot this button is visible
2. I achieved playback in the debugger and made sure step by step that the button is present and located by the above locator name (using the firebug plugin in firefox) present with this locator
After unsuccessful attempts to figure out what the problem is, I decided to do a clumsy workaround, inserting pauses, repeated page refreshes, trying to return to the previous page and go to the problematic one again, all this did not solve the problem.
It is not clear why exactly this button turned out to be problematic, the test uses dozens of other buttons, including delete on other pages, and there were no such problems anywhere.
It is not clear why the problem is reproduced randomly, i.e. in theory, this says that the problem is not in the name of the locator.
Who has any new ideas to offer my desperate brain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
southsoutheast, 2015-11-03
@southsoutheast

had similar problems with watir-webdriver (selenium implementation in ruby).
in each case, the probable causes and solutions were different, so not as a universal solution, but as ideas of what else to try:

  • the element is in a table or frame - it helps to explicitly specify the table/frame first, then the element identifier;
  • there are several such elements (the page was redrawn several times, the old buttons were hidden - don't ask me why, it's not me), and the first one is found, just invisible - refine the request so that it is active;
  • it's just that the element is not found by class and it's not clear why - try to find it by other attributes (id, name, value, xpath, etc.).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question