0

I'm trying to run a test that opens a new window in run time I have a button in my main app that opens a new window with a different name I try to use:

desired_caps["app"] = 'myappname'
driver = webdriver.Remote(
        command_executor='http://127.0.0.1:4723',
        desired_capabilities= desired_caps)
driver.find_element_by_name("OK").click()
#after click on this a new window opens with this name, "Confirmation"
driver.switch_to_window("Confirmation")

I also, try to write in a different way:

webdriver.switch_to.SwitchTo.window(self,"Confirmation")

can anyone help me with this?

danronmoon
  • 3,814
  • 5
  • 34
  • 56

2 Answers2

0

I don't see where you opened a new window. You're trying to switch to a window that isn't open yet?

Try:

driver.get('http://website.com')
0

To Switch between two windows in windows base application we can use...

windows = self.driver.window_handles
self.driver.switch_to.window(windows[0])

by this snippet of code, we can switch between two windows that open in each other. usually Yes or No windows open in the main window and you can switch to that window by this.