I have read previous threads about this issue, but either the threads are old or do not work in my case.
I am using Appium with the following configurations:
Appium.app: v1.4.13
XCode: 7.1
iOS Version: 9.1
Device: iPhone 6 (Simulator and Real device both)
I have a Hybrid iOS application with native views and webviews. The ‘click’ WebElement method works fine for native views. However, on execution upon webviews (in the correct webview context) ‘click’ is performed but nothing happens.
I have tried the following solutions:
- Switching to native context and performing click
Verdict: the element cannot be recognised in the native context - Getting the element location and performing click on that location
Verdict: the location coordinates and the actual coordinates are different - Executing JavascriptExecutor queries (mobile:tap, arguments[0].click() etc)
Verdict: nothing happens - Set nativeWebTap to true
Verdict: no change - Using Selenium TouchActions
Verdict: no change even after implementing ‘HasTouch’ method
Here is my code:
public class RealDevice {
public AppiumDriver driver;
public WebDriverWait wait;
@Before
public void setUp() throws Exception{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "9.1");
//udid and device name capabiliies
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "Selendroid");
capabilities.setCapability("nativeWebTap", true);
capabilities.setCapability(MobileCapabilityType.APP, "path...");
driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
wait = new WebDriverWait(driver, 600);
}
@After
public void tearDown() throws Exception{
driver.quit();
}
@Test
public void testingRealDevice() throws Exception{
System.out.println("PRE EXECUTION");
//Wait for the 'view' button to appear then open the issue
String viewName = "View";
wait.until(ExpectedConditions.presenceOfElementLocated(By.name(viewName)));
driver.findElement(By.name(viewName)).click();
Thread.sleep(3000);
Set<String> availableContexts = driver.getContextHandles();
for(String context: availableContexts){
System.out.println(context);
if(context.contains("WEBVIEW")) driver.context(context);
}
System.out.println(driver.getContext());
Thread.sleep(3000);
WebElement element = driver.findElement(By.xpath("//*[@id='box31']"));
element.click();
System.out.println("CHECKPOINT");
Thread.sleep(5000);
}
}
Note that the element is detected as I’ve fetched it’s attributes and they are correct. However the click operation is not performed on it.
Here is the Appium log for ‘click’
info: [debug] [REMOTE] Executing 'click' atom in default context info: [debug] [REMOTE] Sending javascript command info: [debug] [REMOTE] Remote debugger data sent [{"method":"Runtime.evaluate","params":{"objectGroup":"console","includeCommandLineAPI":true,"doNotPauseOnExceptionsAndMuteConsole":true,"expression":"(function(){return function(){function h(a){return...]