iOS safari app automation using appium

To automate the safari browser in iPhone, you will have to start the iPhone simulator and appium server. In the code, you will have to pass the required capabilities like platformName, platformVersion and AutomationName.

Example - Safari automation in iPhone using Appium

Below example shows how to automate the Safari browser.

package org.softpost.ios.simulator;
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 testSafari() throws Exception{
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("platformName", "iOS");

        caps.setCapability("deviceName", "iPhone 8");
        caps.setCapability("platformVersion", "12.1");
        caps.setCapability("AutomationName" , "XCUITest");


        caps.setCapability(CapabilityType.BROWSER_NAME, "safari");

        driver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps);
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);


        driver.get("https://www.softpost.org");

        Thread.sleep(8000);
        driver.close();
        driver.quit();
    }

}

Web development and Automation testing

solutions delivered!!