Automating iOS Web apps using Appium

Here is the example that shows how to automate web app on iOS device using Appium. Below code will launch safari in iPad and then open www.softpost.org website. Note that Automating the web app on iOS device is similar to automating the website on desktop browser.

package iostests;

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

import java.net.URL;
import java.util.concurrent.TimeUnit;

/**
 * Created by Sagar on 10-07-2016.
 */
public class WebAppTest {
    IOSDriver driver;
    @Test
    public void test1() throws Exception{
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "iOS");
        caps.setCapability("platformVersion", "9.0");
        caps.setCapability("deviceName", "iPad pro");
        caps.setCapability(CapabilityType.BROWSER_NAME, "safari");
        driver = new IOSDriver(new URL("https://0.0.0.0:4723/wd/hub"), caps);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        driver.get("https://www.softpost.org");
        driver.close();
        driver.quit();
    }

}

You may also like...