2
votes

I am having an issue in Selenium which has been recurring through my test suite that reports elements not present after they clearly are, and Selenium even reports that they are via isElementPresent().

For example, I have a page loading with a text field. After selenium.waitForPageToLoad() is complete, selenium intermittently reported the text field missing. To find out if this was a timing issue, I added a Thread.sleep(5000) after the page loads, and to verify the element is present:

logger.debug("Element present status: " + selenium.isElementPresent(elements.get("File Path Text Field")));

The strange thing is, every time I run the script, the page loads with no problems. During the 5 second sleep I can clearly see the text field. EVERY TIME the logger statement above reports "true" for the element being present. The very next line of code is

selenium.type("something");

and it's a craps shoot whether or not it reports the element being present or not. Has anybody else had problems like this and know how to resolve them?

Thanks in advanced.

2

2 Answers

2
votes

If it is an intermittent issue and selenium is finding the element more often than not, then it should be a timing issue. Following are the two steps I would try for this issue:

  1. Change isElementPresent to isVisible. Many a times, I have seen that isElementPresent passes where isVisible fails.

  2. Assuming you are using an IDE for coding the tests, use a breakpoint before the selenium.type command and execute the command. If selenium can 'ALWAYS' find the element during this breakpoint execution, then be rest assured that you have a timing problem.

0
votes

Try selenium.type(elements.get("File Path Text Field"), "something"); As selenium.type method expects two parameters viz. locator and value.