I've Got Invalidargumentexception When I Used Switch_to.window By Selenium / Python
I've seen many example script on how to use selenium switch_to.window Here is an example script regarding what I learned, doesn't work at all: from selenium import webdriver
Solution 1:
Forgot about webdriver chrome/firefox - better use webdriver_manager which manages the latest browsers with your python version More about webdriver_manager can be found here
pip install webdriver_manager
here is the flawlessly code
from webdriver_manager.firefox import GeckoDriverManager
from selenium import webdriver
browser = webdriver.Firefox(executable_path=GeckoDriverManager().install())
script = """
myWindow = window.open("", "ChildWindow", "width=200,height=100");
"""
browser.execute_script(script)
wHandles = browser.window_handles
print(wHandles)
handle = wHandles[1]
print(handle, type(handle))
browser.switch_to.window(handle)
browser.quit()
Post a Comment for "I've Got Invalidargumentexception When I Used Switch_to.window By Selenium / Python"