简体   繁体   中英

C# Selenium - Explicitly waiting By.CssSelector(…)

I am doing an explicit wait with a TimeSpan of 30 seconds and wait.Until(By.CssSelector("#content .data-grid > .data-row")).

I obviously have a data-grid that is being populated here.

Result:

The wait.Until(...) is returned right away (it does not wait for this CssSelector to evaluate with satisfactory results).

Expected result:

I expect there to be a wait until the data is asynchronously returned.

Is this a valid scenario for explicitly waiting?

wait.Until(By.CssSelector("#content .data-grid > .data-row"))

I think you are missing the ExpectedConditions ...

You declare the wait :

WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(30));

Then you add ExpectedConditions here I am using ElementIsVisible for the example:

wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#content .data-grid > .data-row")));

Hope this does the trick!

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