Selenium webdriver using switch_to_windows() and printing the title doesn't print the title.

前端 未结 2 1135
旧巷少年郎
旧巷少年郎 2020-12-06 01:33

Here is the code

for handle in browser.window_handles:
    print \"Handle = \",handle
    browser.switch_to_window(handle);
    elem = browser.find_element_         


        
2条回答
  •  囚心锁ツ
    2020-12-06 01:56

    driver.switch_to_window(driver.window_handles[-1])
    title=driver.title
    

    You can do it simply use the code above. driver.window_handles[-1] would get the lastest window.

提交回复
热议问题