Unable to switch to child window in WinAppDriver
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
please share the code.
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
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.
How can I find that a child window is part of the UI tree?
check in left hand side of inspect.exe it will give the UI tree.
@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.
There are two ways to around the issue:
- Check how many window handles you get and then switch to the second window handle
- Create a root session and acquire a driver session on the child window.