How to convert windows IDs to human readable format using Selenium and Python

Solution 1:

As per the WebDriver Specification of Window Handle:

getwindowhandle

where,

Each browsing context has an associated window handle which uniquely identifies it. This must be a String and must not be "current".

The web window identifier is the string constant "window-fcc6-11e5-b4f8-330a88ab9d7f".

So the output of the following command:

current_windows = driver.window_handles
print(current_windows)

as:

['CDwindow-807A80F3D56E82E4A61529E5898AC71C', 'CDwindow-7CEAB7D7E9B701F6279C4B5C4AEE1A29']

is as per the specification and neither contains the page title information nor can be converted to any human readable format.

To retrieve the page title the only command is:

print(driver.title)