Note that there are some explanatory texts on larger screens.

plurals
  1. POWebDriverWait.until(ExpectedConditions.elementToBeClickable(someAjaxMagic)) never returns
    primarykey
    data
    text
    <p>I have a problem with Selenium. In the following test, it should go to the website, take a product, add it to the cart and go to the cart. In between, it waits for some elements to appear.</p> <p>On my machine the test works fine up to adding the product to the cart. After this, a div is filled with ajax and the test should wait for an element in there. The element appears in the browser, but the test goes on waiting. Even the timeout seems not to be interesting enough to bother it.</p> <p>If I wait with <code>wait.until(pause(2));</code> instead or set <code>driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);</code> everything works fine but this can't be the correct solution.</p> <p>Any idea?</p> <p>My system:</p> <p>MacOS X 10.8.2 or Windows 7 (64 bit)</p> <p>Firefox 17.0.1</p> <p>Java 1.6, JUnit 4.10, selenium-api-2.25.0, selenium-support-2.25.0, selenium-firefox-driver-2.25.0, guava-12.0</p> <p>My test:</p> <pre><code>import static org.openqa.selenium.support.ui.ExpectedConditions.elementToBeClickable; import javax.annotation.Nullable; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.WebDriverWait; import com.google.common.base.Function; public class TestSomeWebsite { @Test public void test() throws Exception { FirefoxDriver driver = new FirefoxDriver(); WebDriverWait wait = new WebDriverWait(driver, 30); driver.get("http://www.obi.de"); // take first product driver.findElement(By.cssSelector("p.product_desc &gt; a")).click(); // add to cart wait.until(elementToBeClickable(By.id("addtocart"))); driver.findElement(By.id("addtocart")).submit(); // go to cart /** everything fine by now **/ wait.until(elementToBeClickable(By.partialLinkText("Zum Warenkorb"))); /** we never come to this point :( **/ driver.findElement(By.partialLinkText("Zum Warenkorb")).click(); } private Function&lt;WebDriver, Object&gt; pause(final int time) { return new Function&lt;WebDriver, Object&gt;() { int count = 0; @Nullable public Object apply(@Nullable WebDriver input) { count++; return count &gt;= time; } }; } } </code></pre>
    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. 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