0

enter image description here

I thought initially that I could retrieve Chrome Windows by using

var windows = await driver.getAllWindowHandles();

Problem with that is that it doesn't actually get Chrome "Window" but Tabs. Is there anyway in Selenium to have a concept of real "visual" Chrome window? I want to know if a Tab is from a specific Window and how many tabs in a Window specifically. The doc is misleading especially with getAllWindowHandles which implies that it's about Window.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
ElixirBolt
  • 21
  • 3

1 Answers1

0

Fundamentally there is no significant difference between a Tab and a Window. The only difference is how it is being presented to an user.

At the core, each Tab as well as each Window can have a totally separate DOM Tree and it's own JavaScript environment.

Get Window Handles

As per the specs:

Get Window Handles

The order in which the window handles are returned is arbitrary.

The remote end steps are:

  • Let handles be a JSON List.

  • For each top-level browsing context in the remote end, push the associated window handle onto handles.

  • Return success with data handles.


Conclusion

To conclude from WebDriver perspective both Tab and Window are treated in the same way.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks for the details, yeah It's what I thought after looking extensively every doc possible... I find it honestly surprising that no-one ever thought of having a concept of Window while it's definitely available in browsers since forever. Really surprising – ElixirBolt Dec 03 '21 at 23:56