WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

Unable to switch to child window in WinAppDriver

Open Ramkrish26 opened this issue 3 years ago • 7 comments

When I launch the winAppDriver and try to switch to child window, I am getting the below error. selenium.common.exceptions.WebDriverException: Message: Missing Command Parameter: name

But when I launch the appium server and run the same code, I am not getting any error and the window is switched to child window.

Appium details: desired_caps = { "deviceName": "device name", "platformName": "Windows", "app": "path to exe", "appWorkingDir": "path to working dir" } driver = webdriver.Remote("http://127.0.0.1:4723", desired_caps)

WinAppDriver: 1.2.1 **Appium: **1.23.0

Ramkrish26 avatar Apr 03 '22 13:04 Ramkrish26

please share the code.

anunay1 avatar Apr 03 '22 16:04 anunay1

Driver initialization: When running via win app driver server driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

When running via appium server driver = webdriver.Remote("http://127.0.0.1:4723", desired_caps)

print("Parent window : "+driver.current_window_handle); Parent_window = driver.current_window_handle; window_list=driver.window_handles; print("window list : "); print(window_list); child_window = driver.window_handles[1]; print("Child window : "+child_window); driver.switch_to.window(child_window)

Output: Parent window : 0x00090EAC window list : ['0x00090EAC', '0x000D0062'] Child window : 0x000D0062 selenium.common.exceptions.WebDriverException: Message: Missing Command Parameter: name

Ramkrish26 avatar Apr 03 '22 16:04 Ramkrish26

It should be other way around:

When running via win app driver server: driver = webdriver.Remote("http://127.0.0.1:4723", desired_caps)

When running via appium server: driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

And if the child window is part of the same UI tree you do not need to switch.

anunay1 avatar Apr 03 '22 16:04 anunay1

How can I find that a child window is part of the UI tree?

Ramkrish26 avatar Apr 03 '22 16:04 Ramkrish26

check in left hand side of inspect.exe it will give the UI tree.

anunay1 avatar Apr 03 '22 16:04 anunay1

@anunay1 It definitely has 2 windows and I changed the remote server URL and tried, Still no luck. If driver isn't switched to the child window it throws element not found exception.

Ramkrish26 avatar Apr 05 '22 03:04 Ramkrish26

There are two ways to around the issue:

  1. Check how many window handles you get and then switch to the second window handle
  2. Create a root session and acquire a driver session on the child window.

anunay1 avatar Apr 05 '22 06:04 anunay1