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.
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.
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.
To run iOS tests, you can follow these steps :
(Note : I am using Java language here in Eclipse IDE and using Appium app):
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.
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..
//install Appium
$ npm install -g appium (or) $ sudo npm install appium -g
//start Appium server
$ appium &
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With