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
from pprint import pprint
browser = webdriver.Firefox()
script="""
myWindow = window.open("", "ChildWindow", "width=200,height=100");
"""
browser.execute_script(script)
wHandles = browser.window_handles
pprint(wHandles)
handle = wHandles[1]
print(handle, type(handle))
browser.switch_to.window(handle)
I've got that error message:
InvalidArgumentException: Expected "handle" to be a string, got [object Undefined] undefined
Obviously i tired with normal web page with same result a as well.
Is there anyone with same problem?