SwitchTo or Window handle is failing when it is executed through webdriver.io
See original GitHub issueThe problem
When we perform a switchTo or window operations from webdriver.io, the POST call made to appium server contains two parameters {"name":"1","handle":"1"}
. And appium servers are throwing an error back saying
Parameters were incorrect. We wanted {"required":["name"]} and you sent ["name","handle"]
.
Environment
Appium Version: 1.7.2 Mac OS : 10.12.6 Node: 8.6.0 Mobile device: iPhone 7(real device) with OS 11.2.6
Details
When we make an switchTo or Window handle from webdriver.io, then it passes the below params to appium server: Logs:
[21:40:08] COMMAND GET "/wd/hub/session/00353d5d-b470-43da-9e56-19e2dc603f4c/window_handles"
[21:40:08] DATA {}
[21:40:08] RESULT ["1"]
[21:40:08] COMMAND POST "/wd/hub/session/00353d5d-b470-43da-9e56-19e2dc603f4c/window"
[21:40:08] DATA {"name":"1","handle":"1"}
When it reached the appium server, i can see the below logs:
[HTTP] --> POST /wd/hub/session/00353d5d-b470-43da-9e56-19e2dc603f4c/window {"name":"1","handle":"1"}
[debug] [MJSONWP] Bad parameters: BadParametersError: Parameters were incorrect. We wanted {"required":["name"]} and you sent ["name","handle"]
[HTTP] <-- POST /wd/hub/session/00353d5d-b470-43da-9e56-19e2dc603f4c/window 400 2 ms - 89
So it looks like, appium server is so strict that it accepts only name
.
Here is the simple sample code to switchTo a window in wdio:
var wins = browser.windowHandles();
console.log('WINDOWS: ' + wins.value.length);
console.log('WINDOWS: ' + wins.value[0]);
for(let i=0; i<wins.value.length; i++){
browser.window(wins.value[i]);
console.log('A switch is performed');
}
NOTE: The same switching windows works fine through Java with selenium. There appium server gets only name
in the params.
Thanks, Naveen.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top GitHub Comments
Hi Team, Could someone please provide an update. This is blocking from automating a app that switches to browser.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.