简体   繁体   中英

Is there a way to check whether ChromeDriver is busy in Selenium

I'm running Selenium with ChromeDriver WebDriver . On the page there is a heavy synchronous javascript that can run for very long time (up to even 30 minutes)

On this page I have a function getStatus() that returns whether the task has finished, but when I execute browser.ExecuteScript("return getStatus()") of course this fails by timeout because the page can't execute this javascript as it is working on another js execution.

Are there any other way for Selenium or Chrome WebDriver to tell me whether there are any heavy javascript is currently being executed?

My full code:

var chromeOptions = new ChromeOptions();
//chromeOptions.AddArguments("headless");
using (var browser = new ChromeDriver(chromeOptions))
{
    browser.Url = url;
    while (true) {          
        Dictionary<string, object> status =
                            (Dictionary<string, object>)browser.ExecuteScript("return getStatus()");
        if ((bool)status["Finished"]) {
           return
        }
    }
}

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