Automating native app in iOS automation using appium

Here is the simple example to test the app on iPhone simulator. To run scripts on real iOS device, you will need one more capability – ‘UDID’ (Device ID)
 
package iostests;

import io.appium.java_client.ios.IOSDriver;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.URL;

/**
 * Created by Sagar on 10-07-2016.
 */
public class NativeAppTest {
    IOSDriver driver;
    @Test
    public void test1() throws Exception{
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "iOS");
        caps.setCapability("platformVersion", "9.0");
        caps.setCapability("deviceName", "iPhone 6s");
        caps.setCapability("app", "/usr/myapp1.app");
        driver = new IOSDriver(new URL("https://0.0.0.0:4723/wd/hub"), caps);
        driver.findElement(By.xpath("//UIAStaticText[3]")).click();
        driver.quit();
    }

}

Complex problems, Simple Solutions