How to identify the window handle associated to the current active element (Chrome, WebDriver)

46 views
Skip to first unread message

Daniel Ricci

unread,
Jan 29, 2020, 2:41:41 AM1/29/20
to Selenium Users

Im using WebDriver and Chrome

Let's say that I have 3 chrome windows opened.

How do I go about finding out the WindowHandle associated to the current active element of the web driver. I am looking at the window handles and they look like gibberish to me.

Alex K

unread,
Jan 29, 2020, 9:44:43 AM1/29/20
to Selenium Users
the gibberish you are referring to is a unique identifier of every tab. To answer your question - you probably can iterate over the tabs and use document.activeElement command via js executor to find the active element
Reply all
Reply to author
Forward
0 new messages