Appium iOS Setup for Native Apps Automation
Appium is an open source cross-platform automation tool. It can be used for automation of iOS and Android native, web and hybrid mobile apps. Now that we have seen how to setup Appium for Android app automation, we’ll cover Appium iOS setup in this tutorial.
To setup Appium for iOS automation, you will need Xcode. That means Appium iOS setup can only be done in Mac OS. Automation is possible on actual iOS device or simulator. In our example, we will automate UICatalog app on simulator. But you can as easily use your actual iOS device. It’s just a matter of changing one of the “capabilities”. As for programming language, we will be using Java here.
This tutorial is divided in two parts: 1) Setting up required dependencies for Appium and 2) Executing a simple test case on simulator. If you already have environment setup for Appium, you can directly jump to part 2.
1) Setting up required dependencies for Appium iOS setup:
- Download and install Xcode in your Mac system.
- Download Appium. Unpack downloaded dmg file and move it to Applications folder.
- Download sample iOS app(UICatalog) from here.
Once the above setup is done, we can now proceed to automate a simple test case using Appium.
2) Executing a simple test case on iOS simulator:
- Open Xcode from Applications folder.
- Start iOS simulator from Xcode–>Open Developer Tool–>iOS Simulator option.
- Click Appium icon from Launchpad/Applications. Appium console should be opened.
- Select Apple icon from Appium console and click Launch button. Appium server should start at http://0.0.0.0:4723/wd/hub address as shown in below image.
- Open Eclipse and write below code in your Class file. You will need to reference Appium Java Client JAR and Selenium JAR in your project.
123456789101112131415161718192021222324252627282930313233343536373839package com.AppiumTest;import io.appium.java_client.ios.IOSDriver;import java.net.MalformedURLException;import java.net.URL;import org.openqa.selenium.By;import org.openqa.selenium.remote.DesiredCapabilities;import org.testng.annotations.AfterMethod;import org.testng.annotations.BeforeMethod;import org.testng.annotations.Test;public class AppiumiOSTest {private IOSDriver driver;@BeforeMethodpublic void setUp() throws MalformedURLException {DesiredCapabilities caps = new DesiredCapabilities();caps.setCapability("platformName", "iOS");caps.setCapability("platformVersion", "8.2"); //Replace this with your iOS versioncaps.setCapability("deviceName", "iPhone 6"); //Replace this with your simulator/device versioncaps.setCapability("app", "/Users/username/Downloads/UICatalog.app"); //Replace this with app path in your systemdriver = new IOSDriver(new URL("http://0.0.0.0:4723/wd/hub"), caps);}@Testpublic void testiOS() throws InterruptedException {driver.findElement(By.xpath("//UIAApplication[1]/UIAWindow[2]/UIATableView[1]/UIATableCell[1]/UIAStaticText[1]")).click();driver.findElement(By.name("Back")).click();}@AfterMethodpublic void tearDown() {driver.quit();}} - Run your Test!
We hope you would be able to perform successful Appium iOS setup using above instructions.
Happy Appium Testing 🙂
I have XCode and I have installed Appium…what do u mean by “Open Eclipse and write below code in your Class file. You will need to reference Appium Java Client JAR and Selenium JAR in your project.”
Which class file are you talking about?
Where do I get the Appium Java client JAR and Selenium JAR, and how do I reference them?
It’s not clear to me!
look, u need to install eclipse on mac .appium is required in xcode as its ios version can run on xcode.
Let me know if u have any problems.
you can download selenium jar files for java from this link. http://www.seleniumhq.org/download/
I am getting The constructor RemoteWebDriver(URL, DesiredCapabilities) is undefined. Can somebody please help??
hi ..
i want to test fandango app .. how can i get .app file for this app..
Download sample iOS app(UICatalog) from here.
Link is not working 🙁
Corrected. Thanks for pointing it out.
Thanks for sharing this information.It was very nice blog to learn about Appium.
http://thecreatingexperts.com/appium-training-in-chennai/
Hi,
Great Job. Actully i want to run on real device so could you help me to get BundleID of this app..
Thanks,
Naga Raju N
Hi,
I am getting error “could not start a new session. “etc…
using selenium 2.48.2 jar
mac machine, iOS,
appium (latest)
Hello
Getting issue as :
FAILED CONFIGURATION: @BeforeClass setUp
java.lang.Error: Unresolved compilation problem:
driver cannot be resolved
My code is:
package Package;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class AddJuiceBox {
private IOSDriver driver;
@BeforeMethod
public void setUp() throws MalformedURLException{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“appium-version”, “1.0”);
capabilities.setCapability(“platformName”, “iOS”);
capabilities.setCapability(“platformVersion”, “9.2”);
capabilities.setCapability(“deviceName”, “iPhone 5s”);
capabilities.setCapability(“app”, “/Users/administrator/Library/Developer/Xcode/DerivedData/JuiceNet-duvjjdhcmonbmxeziudkdcyxmjqi/Build/Products/Debug-iphoneos/EV JuiceBox.app”);
driver = new IOSDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
@Test
public void testiOS() throws InterruptedException
{
driver.findElement(By.name(“Start”)).click();
driver.findElement(By.name(“Follow the steps in this Installation Guide”)).click();
}
@AfterMethod
public void stop()
{
driver.quit();
}
}
Please Help !!!
UICatalog app is working fine for my configuration but when i am trying to input any other .app(Flipkart in my case) file it is not executing. Can you please help me.
Thanks in Advance
I followed all the instructions above, and getting ‘…Could not extract Info.plist from application. Plist does not exist : /Users/username/Downloads/UICatalog.app/infor.plist’
I have native app on my iOS real device to automate. How to get path which is on Real device Homescreen ?