Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up appium for iOS app test automation [closed]

Looking far and wide for a step-by-step guide to set-up iOS Test Automation using appium, with scripts in Java (no ruby and/or cucumber).

Note: The appium wiki is not helpful either.

like image 986
Ravi Gupta Avatar asked Dec 22 '13 15:12

Ravi Gupta


People also ask

Can we automate iOS app using Appium?

To begin iOS automation with Appium today, please use the XCUITest Driver instead. Appium's former method for iOS app automation was based on UIAutomation , an Apple-provided framework that shipped with the iOS SDK until iOS 10, when it was removed.

How do I run Appium tests on an iOS device?

Start the Appium server (by opening the Appium Desktop app or using the CLI). Run the Java test you wrote including the capabilities above, and watch as the iOS device opens your app! Make sure the device is unlocked, and if it asks you to "Trust the Computer", tap the button to trust our Mac.


2 Answers

To run iOS tests, you can follow these steps :

(Note : I am using Java language here in Eclipse IDE and using Appium app):

  1. Create a new java project in Eclipse.
  2. Import jar files : Selenium Server (formerly the Selenium RC Server) version and required client driver (according to your language choice) which can be downloaded here. (To import : Right click on your project -> Properties -> Libraries -> Add External JARs. Add all three selenium jar files here.)
  3. Download Appium app and launch.
  4. You can run your test scripts either in simulator or on real device. To run scripts on real iOS device, you will need 'deviceName', 'platformVersion', 'UDID' (Device ID) and 'Bundle ID' (Application Bundle ID) and absolute path to the .ipa.
  5. To run scripts on iOS simulator , you will need 'deviceName', 'platformVersion', path to .app and 'Bundle ID' of your app.
  6. Choose capabilties in Appium app and mention the same in your script based on whether you are testing on simulator or on device.
  7. Launch Appium server and then run your script.

All Appium server capabilities which can be used can be found here.

You can refer to my blog post here as well for more details to execute a sample basic script.

like image 88
Smriti Avatar answered Sep 19 '22 16:09

Smriti


I found this very helpful.

http://seleniumworks.blogspot.co.uk/2013/12/appium-native-ios-app-testing-webdriver.html

Note you need to get the .app of your project for it to work - not the .ipa

Appium Native iOS App Testing | WebDriver Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web apps. Appium tests can be written in your favorite Webdriver-compatible language.

Requirements & installation

1| MAC OS X 10.7 (minimum version required) 2| Xcode updated version (prefer) 3| Node.js 4| Appium.app 5| Eclipse Kepler (prefer) 6| TestNG framework

Pre-Appium setup

iOS .app file is enough to inspect elements. In this example, I have used the project, 'InternationalMountains' from Apple DEV site.

1| Download the project, 'InternationalMountains' 2| Double click and extract it 3| Import it into Xcode by opening the Xcode file 4| Run the project 5| Make sure that the simulator is opened with the application 6| Open Terminal and move to the project folder 7| Run the following command to build the .app file

`xcodebuild -sdk iphonesimulator6.1`

8| It will build the app and generate the file, 'InternationalMountains.app' under /InternationalMountains/Build/Products/Release-iphonesimulator/

Appium iOS setup

1| Download & Install Node.js // npm represents that Node.js Package Manager $ sudo npm install wd

2| Run the Appium server using node.js; There are couple of ways to do so..

1 Using Node.js

//install Appium $ npm install -g appium (or) $ sudo npm install appium -g //start Appium server $ appium &

2 Using the App

Download Appium, install and Run it

3| Now, the Appium server gets started in the

default port 4723 and IP Address 0.0.0.0

Appium inspector

Appium inspector is a record and playback tool just like Selenium IDE for web.

1| Open Appium

2| Change the default IP address to 127.0.0.1 and port 4725

3| Now, enable the check box, 'App path' 4| Click on the 'Choose' button and locate the .app local directory. i.e., InternationalMountains.app

5| Click on the 'Launch' button [Appium server launches now] 6| Now, a blue-colored icon found beside the 'Launch' button is enabled 7| Clicking blue-colored icon open up the Appium inspector with Simulator 8| Now, click the 'Record' button in Appium inspector 9| Every action will be generating a script at bottom of the Appium inspector

Run the script in Eclipse IDE

package packagename;

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

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class AppiumTest {
public WebDriver driver = null;

@BeforeMethod
public void setUp() throws Exception {
// set up appium
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
capabilities.setCapability(CapabilityType.VERSION, "6.1");
capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
capabilities.setCapability("app","/Users/username/Downloads/InternationalMountains   /build/Release-iphonesimulator/InternationalMountains.app");
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);
}

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

@Test
public void test01() throws InterruptedException {
driver.findElement(By.xpath("//window[1]/tableview[1]/cell[2]")).click();
driver.findElement(By.xpath("//window[1]/navigationBar[1]/button[1]")).click();
driver.findElement(By.xpath("//window[1]/tableview[1]/cell[7]/text[1]")).click();
}
}

Note: 1| Currently, there is no Appium inspector support for Windows

like image 45
Bob Avatar answered Sep 19 '22 16:09

Bob