简体   繁体   中英

Wait for class name to be empty - Selenium Webdriver - Java

With the following code, the class for the current screen that's dislayed will ="active".

In the case below, the Payment History screen is currently shown (a ui-sref="paymenthistory")

<ul id="myTab" class="nav nav-layout-sidebar nav-stacked">

<li class="" ui-sref-active="active">
<a ui-sref="paymentmethods" href="#/user/payment-methods">
</li>

<li class="active" ui-sref-active="active">
<a ui-sref="paymenthistory" href="#/my-account/payment-history">
</li>

<li ui-sref-active="active" class="">
<a ui-sref="password" href="#/user/change-password">
</li>

</ul>

I'm trying to wait for a specific page to be loaded, however, I'm not sure how to specify the screen.

The following obviously doesn't work because there is always an li class that equals active.

WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("li[class='active']")));

Basically, I'm trying to figure out how to say, wait for the paymentmethods screen to be active

I'm trying to figure out how to say, wait for the paymentmethods screen to be active

Then, ask for two conditions to be true at the same time:

wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("li.active > a[ui-sref=paymentmethods]")));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM