Python Selenium: Switch tab without waiting for page to load

536 views Asked by At

I am trying to change the browser tab while the current tab I am in is loading some javascript. When I try to do that, my program stops in the driver.switch_to.window(x) line and stays there until the javascript is loaded. I would like to know If there is any way not to block the execution.

It's like the driver it's busy, and will not do the action until it finishes.

1

There are 1 answers

2
undetected Selenium On

No, you can't change the browser tab using driver.switch_to.window(x) while in the current tab the page is loading some javascript.


Deep Dive

When you invoke get() the the client (i.e. the Web Browser) returns back the control to the WebDriver instance once 'document.readyState' equals to "complete" is achieved. Till then you won't be able to execute any command through the WebDriver.


References

You can find a couple of relevant detailed discussions in: