Home Appium Environment Setup Android Emulators iOS Simulators Appium Architecture Android chrome app automation Safari browser automation Appium Capabilities Inspecting android apps Native Android app automation Inspecting iOS app Native iOS app Automation Real Android Phone automation Real iPhone automation Element Identification Pressing button FaceId and TouchId Fingerprint automation Drag and Drop Tap and press Swipe gestures Hybrid app automation Execute script Synchronization in Appium Screenshots Page Object Models Cucumber and Appium Appium integration with azure Appium and Selenium Grid Running tests in browserstack Parallel testing Recording tests Mobile automation framework Errors and Exceptions in Appium Mobile automation test strategy Mobile automation challenges Appium QnA
Native iOS app automation using appium
To automate the native app in iPhone, you will have to start the iPhone Simulator and appium server. If you encounter error saying "Keyboard is not present", You will need to ensure that software keyboard is toggled in iOS simulator setting. Basically you need to ensure that when try to type something in simulator, keyboard is being displayed.
Example - Address book app automation using Appium
Below example shows how to automate the address book app in iOS Simulator.
package org.softpost.ios.simulator;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.touch.offset.PointOption;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import java.util.concurrent.TimeUnit;
/**
* Created by Sagar on 10-07-2016.
*/
public class NativeAppTest {
AppiumDriver driver;
@Test
public void testContacts() throws Exception{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platformName", "iOS");
caps.setCapability("platformVersion", "12.1");
caps.setCapability("deviceName", "iPhone X");
caps.setCapability("AutomationName" , "XCUITest");
//caps.setCapability("connectHardwareKeyboard", false);
caps.setCapability("bundleId", "com.apple.MobileAddressBook");
try {
driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebElement e = driver.findElement(By.xpath("//XCUIElementTypeButton[@name="Add"]"));
TouchAction action = new TouchAction(driver);
//action.tap(new PointOption().withCoordinates(330,20));
action.tap( PointOption.point(e.getLocation())).perform();
//e.click();
driver.findElement(By.xpath("//XCUIElementTypeTextField[@name="Last name"]")).sendKeys("abc");
Thread.sleep(2000);
}catch (Exception ex){
ex.printStackTrace();
}finally {
driver.quit();
}
}
}
Web development and Automation testing
solutions delivered!!