Python Selenium gets current window handle

Selenium for Java and Ruby have methods for getting the current window handle.

For example, in Java, he pointed out here .

At the same time, the Pythonic version of Selenium does not have such a method.

  • Maybe inside, but I don’t see it?
  • If he misses, is this reasonable and how to do it in a workaround?
+6
source share
1 answer

There is a current_window_handle property available in an instance of WebDriver :

 driver.current_window_handle 

Demo:

 >>> from selenium import webdriver >>> >>> driver = webdriver.Chrome() >>> driver.get('https://stackoverflow.com') >>> >>> driver.current_window_handle CDwindow-B22C1E54-977D-4B2A-8048-E9C73999E9C7 
+9
source

Source: https://habr.com/ru/post/980145/


All Articles