Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>heh, come across with similar issue. The matter is when you got a lot of AJAX on the page, the best way (imho) to handle it and the wait i like most is <code>fluentWait()</code></p> <pre><code> public WebElement fluentWait(final By locator){ Wait&lt;WebDriver&gt; wait = new FluentWait&lt;WebDriver&gt;(driver) .withTimeout(30, TimeUnit.SECONDS) .pollingEvery(1, TimeUnit.SECONDS) .ignoring(NoSuchElementException.class); WebElement foo = wait.until( new Function&lt;WebDriver, WebElement&gt;() { public WebElement apply(WebDriver driver) { return driver.findElement(locator); } } ); return foo; }; </code></pre> <p>So you actually need to find the locator of web element (xpath, or css selector) and to pass it to fluent wait. And fluent wait, in turn, returns you found web element. From the documentation: <em>An implementation of the Wait interface that may have its timeout and polling interval configured on the fly. Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.</em> <strong>usage:</strong></p> <pre><code>String xPathElement =".....blablabla..."; WebElement neededElement =fluentWait(By.xpath(xPathElement)); neededElement.click(); //neededElement.getText().trim(); </code></pre> <p>you can get more info on it <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/ui/FluentWait.html" rel="nofollow">here</a></p> <p>The issue causing such kind of problem can be (from my experience ) of two types: 1) first one</p> <p>you interact with an element causing page rendering or some else 'slow' operations. Selenium tests keep on going but the page actually not rendered >> <code>staleElement</code>.</p> <p>2) second one. you interact with one element. then you interact with another causing a lot of AJAX (not complete page reload, and first element refresh). and instantly you return back to the previous one (wanna e.g. getText or click)>><code>staleElement</code>.</p> <p>So I always use fluent wait. It is comfortable from the point you can set up arbitratry exceptions ignoring. Hope this works for you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload