Appium iOS: Setup Appium for iOS testing

Last updated on:

package com.something.test;

import io.appium.java_client.remote.HideKeyboardStrategy;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.AppiumDriver;

import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.io.File;
import java.net.URL;
import java.util.HashMap;


/**
 * Test Mobile Driver features
 */
public class MobileDriverIOSTest {

// in 2014 WebDriver was replaced with AppiumDriver
	
public static AppiumDriver driver;

  @BeforeMethod
  public void setup() throws Exception {
 
     DesiredCapabilities capabilities = new DesiredCapabilities();
	   capabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "");
	   capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "7.1");
	   // platform name is not required anymore since AppiumDriver now using
	   // IOSDriver and Android
	   // capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS");
	   capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone");
    capabilities.setCapability("udid", "23333fdgsd333333fdgfd3333fgd3333344444444");

    // driver = new RemoteWebDriver( new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  }

  @AfterMethod
  public void tearDown() throws Exception {
    driver.quit();
  }

  @Test
  public void firstTest() {
	/*
      Tests code goes here
       */
  }  

}
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.