I am writing a test for a hybrid app which contains a iframe inside a webview and I'm trying to click a button inside the iframe.
It worth mentioning that the data inside the iframe is in another origin. Nevertheless, I managed to switch to the iframe and I can see the content of it (also getting element).
This is the sequence of commands I run
return driver
.contexts().then(function (contexts) {
return browser.context(contexts[1]); // choose the webview context
})
.frame('myFrame") //switch to iframe
.getElementById('myButton')
.click() //try to click button
It work fine on an iOS simulator, but on the Android it does nothing. The test continues to run, but no action is made.
I'm running Appium 1.2.2 with nodejs wd client and Genymotion 2.2.2 I also tried it on a real android device and on the Andorid SDK emulator - none of them worked.
Well, I managed to work around it. I used xpath to find the element and then used tapElement() to make the magic happen.
return driver
.contexts().then(function (contexts) {
return browser.context(contexts[1]); // choose the webview context
})
.frame('myFrame") //switch to iframe
.elementByXPath('//li[div/span[contains(text(),"Data I want")]]')
.then(function(el){
return driver.tapElement(el);
})
I opened an issue about it in appium's github and will also open one in wd's github.
You can chain the element method using .tap():
.elementByXPath('//li[div/span[contains(text(),"Data I want")]]')
.tap()