Selenium: don't wait for asynchronous resources

Selenium expects calls to asynchronous resources before moving to a new page.

Ref.

<script src="https://apis.google.com/js/platform.js" async defer></script>

On a website with many external apis (such as Google Analytics and share them with G +, Facebook and Twitter). Selenium spends more time waiting for asynchronous calls than when running tests.

Is there a way to disable this behavior so that selenium does not wait for asynchronous external api calls?

+4
source share
2 answers

In action, you see page load time . You can configure it and handle a timeout exception:

try:
    driver.set_page_load_timeout(5)  # in seconds
except TimeoutException:
    pass

# continue with testing

Explicit Wait, , .


, , , . , Google Analytics:

, CSS flash ( ):

+3

, , , (, find_element)

FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable");
WebDriver driver = new FirefoxDriver(fp);

: https://code.google.com/p/selenium/wiki/FirefoxDriver#-Beta-_load_fast_preference

0

Source: https://habr.com/ru/post/1606022/


All Articles