SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.63k stars 8.18k forks source link

[🚀 Feature]: support a 'network is idle' heuristic #11800

Closed joerg1985 closed 1 year ago

joerg1985 commented 1 year ago

Feature and motivation

I have done some tests with playwirght and there is a networkidle heuristic to detect if the page is fully loaded. This is very handy if you are dealing with alot of dyamically loaded containers with shadow-roots.

My current approach is to search the DOM via JavaScript for "loading" elements, to wait for the application to be ready. I need to customize this script for each and every application / framework i am testing.

The networkidle heuristic would be a very generic approach to detect the loading state of any application and would help alot of people dealing with dyamically loaded containers.

I don't know any option (for all browsers) to implement this on my own. Prehaps the BiDi protocoll could help to implement something like this in the future?

Usage example

// this is pseudo code WebDriverWait wait = new WebDriverWait(driver, Duration.ofMinutes(1));

wait.until(ExpectedConditions.networkIsIdle(Duration.ofSeconds(1)));

github-actions[bot] commented 1 year ago

@joerg1985, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

diemol commented 1 year ago

I think it does make sense, but we would not add it directly in Selenium right away. I suggest to check the WebDriver BiDi uses cases, and if you do not find it, can you please create an issue in that repository? Then it can be considered and it will potentially work in all browsers.

If you end up creating an issue, please share the link here so we can follow up.

titusfortner commented 1 year ago

Network module just landed in BiDi spec

@pujagani / @shs96c / @AutomatedTester — I think I'm right that Network Interceptor class can be implemented as is with BiDI? We still need to move it from devtools to bidi module?

At any rate, creating a tool that allows waiting for this should be straightforward? Would *love to promote this functionality.

github-actions[bot] commented 10 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.