selenium webdriver timing problems

I have timing problems. I use explicit and implicit waits, but thee are not enough. Since then I found a nice function that waits for the ajax requests to be complete. It helped a lot, but there are still timing problems I guess.

This is an example when I try to check a simple text on the page:

assertTrue(driver.findElement(By.xpath(“//[@id=’resultsForm’]/div/div[1]”)).getText().contains(“Zarolt fedezetek”));

Test randomly fails about 2-3 times of 10. However the text is present when I debugging the test while running.

Sorry for my English, I hope it’s understandable.

bodidani Default Asked on February 6, 2015 in Software Testing.
Add Comment
1 Answer(s)

You have to use expected condition wait here. Which means that you would wait till the element is displayed and once it is displayed you will move forward and fetch the text of the element and do your assert.

http://www.toolsqa.com/selenium-webdriver/wait-commands/

Virender Singh Professor Answered on February 23, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.