0

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.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Pere Coll
  • 49
  • 5
  • There's a way to do it by changing page load strategy but I don't know it offhand. Pyppeteer might be a good alternative. – pguardiario Apr 18 '22 at 01:49

1 Answers1

0

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352