Selenium waitForCondition

ajax, selenium

Solution

`waitForCondition` is for Javascript calls only, not for waiting for elements to load.

What you have in `isElementPresent` is fine. I would combine it with explicit waits to be a bit more accurate about when an element is actually loaded and present on the screen:

http://seleniumhq.org/docs/04_webdriver_advanced.html

Problem

I am doing Selenium testing for the first time. On the homepage, I call some AJAX, and i want Selenium to wait for the element to load finish. I not sure it works, but i just type selenium and the waitForCondition are able to choose. I not matter what I choose it always return "false". I do not now if the waitForCondition even work? How can I test if it works? And what am I doing wrong in this codes? ``` selenium.waitForCondition("//input[@name='Report'", "3000"); selenium.waitForCondition("//*[@id='MyTable']", "3000"); selenium.waitForCondition("css=.someClass2", "3000"); ``` If I implement by own class - it return "true" ``` private boolean isElementPresent(By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; } } ``` isElementPresent(By.xpath("//*[@id='MyTable']")) - return "true"

Original source