This time I started with a new tool which I had heard about earlier but didn’t start working on it. Earlier I had worked for some time on UI Automation Library using Instruments tool for iOS automation.

Appium – an open source, cross-platform test automation tool which can be used for native, hybrid and mobile web apps. It requires :

  • Mac OS X 10.7 or higher, 10.8.4 recommended
  • XCode >= 4.6.3

It drives various native automation frameworks and provides an API based on Selenium’s WebDriver JSON wire protocol. It drives Apple’s UIAutomation library for iOS support.

 

Appium can be useful for automation as :

  • We can write tests with Selenium WebDriver API and language specific client libraries with any of the WebDriver compatible language say Java , Objective-C , Javascript , PHP , Python , C# , Ruby , Clojure or Perl.
  • Any testing framework can be used.

So I thought of trying this tool out with Java language in Eclipse as I have been using the same for my Android automation as well and I chose TestNG framework. Testing framework will be required if you want any way to log your results for your purpose otherwise you can even skip this.

 

To start with , you will be need :

  • Selenium Server in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones.
  • Language specific client drivers
  • TestNG framework (optional)
  • Appium app to launch appium server
  • Eclipse
How  to  use  Appium

  • Appium uses ‘Appium Inspector’ to view the elements similar to what we have as ‘uiautomatorviewer’ tool to view UI components in Android in UI Automator. You can access elements using name , xpath or tagName as visible through appium inspector.
  • Appium Inspector can be launched by clicking on the blue ‘i’ button besides ‘Launch’ button from appium app.
  • Through appium inspector – you can view name , value , label , xpath of different elements on the screen.

Some examples how to use elements from the screen using xpath , class name, name, id is here –

//driver declaration
public AppiumDriver<MobileElement> driver;
public WebDriverWait wait ;      

//using xpath
driver.findElementByXPath("//window[1]/scrollview[1]/button[1]");

//using accessibility_id ('name' and 'label' locators in inspector are used as 'AccessibilityId')-
driver.findElementByAccessibilityId("").click();

//using class name ('type' locator is used as 'className')
driver.findElementsByClassName("")

//using id ('value' locator is used as 'id')
driver.findElementsById("")

//sendkeys can be used for giving some input in any field
driver.findElementById("org.email.android:id/email_username").sendKeys("xyz@gmail.com");

//provide delay between two events:
1. explicit wait:
 * Thread.sleep(time in milliseconds);
 * wait.until(ExpectedConditions.presenceOfElementLocated(By.id()); where wait = new WebDriverWait(driver, 20);
2. implicit wait:
 * driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

 

 

NOTE  To run automation scripts for iOS , you need a Mac machine. It can’t be done on Windows as Xcode needs to be present for Appium to work. 

You will not be able to test iOS apps on a locally hosted server, because Apple’s instruments binary, which Appium uses to launch the iOS simulator by default uses the currently-selected Xcode, and the highest iOS SDK installed with that version of Xcode.

 


 

Executing  Basic  Script –

 

FIRST  STEP : Creating  a  new  project

[1] Create a new java project in Eclipse :

  • Go to ‘File’ -> ‘New’ -> ‘Java Project’

new_java_project

 

 

[2] Add project name and click ‘Next’ –

project_name

 

[3] Click ‘Finish’ –

project_name_settings

 

[4] Expand your project. Right click on src folder -> ‘New’ -> ‘Class’ –

new_class

 

[5] Enter ‘Name’ for class. Also mention ‘Package’ and then click ‘Finish’ –

class_name

 

[6] You will see something like –

empty_project

 

 

SECOND  STEP : Adding  required  jar  files

[1] You will need to export required selenium jar files and install your testing framework (if required) in your project.

For that , download :

i) Selenium Server (formerly the Selenium RC Server) version and

ii) Required client driver (according to your language choice) under – Selenium Client & WebDriver Language Bindings.

Selenium server and client drivers can be downloaded from here – http://docs.seleniumhq.org/download/ .

 

[2] Import all these jar files in your project.

Right click on your project -> Properties -> Libraries -> Add External JARs. Add all three selenium jar files here.

selenium_jars

 

Optional – If you want to use TestNG  :  Go to Help -> install new software -> use http://beust.com/eclipse/ :

TestNG

 

THIRD  STEP

Download Appium app depending on your platform either Mac/Win –https://bitbucket.org/appium/appium.app/downloads/ 

You can use  ‘IP Address’ as ‘127.0.0.1’ and port ‘4723’.

 

FOURTH  STEP 

To run scripts on real device , you will need “UDID” (Device ID) and “Bundle ID” (Application Bundle ID) of your app :

real_device_run_settings

To run scripts on simulator , you will need “.app” and “Bundle ID” of your app (Force device also can be left unchecked)  :

simulator_run

NOTE : You can run your test scripts either in simulator or on real device but I would recommend using iOS simulator as it responds faster than real device. Desired capabilties need to be updated depending on whether you run on simulator or real device.

(Desired capabilities are a set of keys to communicate with Appium server to tell the server what kind of automation session you are interested in).

To Run on Simulator 

public AppiumDriver<MobileElement> driver;

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
capabilities.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir") + "/build/SampleiOS.app");
driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

 

To Run on Real Device –

public AppiumDriver<MobileElement> driver;

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
capabilities.setCapability(MobileCapabilityType.UDID, "6gt72bfbi38sehi42");
capabilities.setCapability(MobileCapabilityType.APP, System.getProperty("user.dir") + "/build/SampleiOS.app");
driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

 

There are two ways to get the “.app” of your application :

[1] You can build your app using xcode. Not down the build path of your application – that would be the location where your ‘.app’ file will be created.

Ex – I ran my build on iPhone 6 simulator , 9.1. My ‘.app’ was generated at the following path :

‘/Users/Library/Developer/Xcode/Derived Data/#{your codebase}/Build/Products/Debug-iphonesimulator/#{your .app file}’.

[2] If your app is in store :

– Download app from itunes store. Then open that file in finder.

– There will be one plist file -> you can get bundle id from there.


BASIC  SCRIPT –
package com.iostest.appium;

import java.net.URL;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class TestCases {

  String addRecipe = "Add";
  String receipeName = "Recipe Name";
  String saveRecipe = "//UIAApplication[1]/UIAWindow[2]/UIANavigationBar[1]/UIAButton[3]";

  public AppiumDriver<MobileElement> driver;
  public WebDriverWait wait;

  @Before
  public void setUp() throws Exception {
    // set up appium for android instance
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 6");
    capabilities.setCapability(MobileCapabilityType.APP, "/Users/smriti/iPhoneSimulator/SampleApp.app");
    driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    wait = new WebDriverWait(driver, 30);
  }

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

  @Test
  public void addRecipe() throws InterruptedException {

    // click on add recipe (using accessibility id)
    driver.findElementByAccessibilityId(addRecipe).click();
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id(receipeName)));

    // add recipe (using id)
    driver.findElementById(receipeName).sendKeys("TestRecipe");

    // save recipe (using xpath)
    driver.findElementByXPath(saveRecipe).click();
    wait.until(ExpectedConditions.elementToBeClickable(By.id("Recipes")));

    // navigate to home page
    driver.findElementByAccessibilityId("Recipes").click();

  }
}

 

  • I copied my ‘.app’ file from that location to a folder in my local here – ‘/Users/smriti/iPhoneSimulator. That is what it shows in code :
capabilities.setCapability(MobileCapabilityType.APP, "/Users/smriti/iPhoneSimulator/SampleApp.app");

 

  • @BeforeMethod is for appium setup and app launch.
  • @Test is for writing all test cases after app launch .
  • @AfterMethod is after test cases are complete.

 

I have started using appium for native mobile iOS apps automation. Let’s see how it goes 🙂

Share if you like : Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

290 comments on “iOS Mobile Automation using Appium

    • Hi Smriti
      I am new to appium
      When i am launching the appium inspector then it gives me an error regarding instrumentation
      and
      failed to install the App on device
      I am using appium version 1.4 and Xcode 6.1 series and real device

  • Hi All,

    Please tell me can i automate the ios native application with out having the source code using appium.

    Thanks,
    Jitendra

  • Hi Smriti,

    Thanks for quick response…my question was if i have downlaoded few apps in ios (Facebook, twitter and many may more) so can i start automation with apium. As i read in few articles that we need source code of application to automate. This was my question.

    • It depends actually what kind of use cases you are trying to automate. Not for all , you would need source code.
      I actually automated one native browser for which only for one test case I required the source code. All other test cases were easily automated by using either name , xPath , attribute or tagName with the help of Appium Inspector.

      • Apps such as facebook , twitter would be having one of these parameters defined ( I observed their parameters like description , text etc. declared when I was doing android automation using uiautomator) so you can use any of them and use them.

  • Hi Smriti,

    Your document is quiet useful but when I am trying to run the script generated by Appium inspector through eclipse kepler using Junit, it does nothing. Not sure why it is reacting so strange.

    We are using OS 10.8.5 and XCode 5 and Appium 0.12.3. Please respond if you get any clue about the same..

    • Hey Deepthi

      Can you post your code here so I can have a look. Also can you check console if something shows up there when you run the script.
      Also can you try running it as normal Java application or TestNG instead of JUnit.

      • Thanks alot for your reply Smriti. Now simulator works fine with eclipse. Now my problem is how to run my scripts using real device.(IOS)
        Can you please tel what are the things need to follow to connect to a device.Also can you put One example code to run script using real device. Mainly What are the Capablities need set in the code.

  • Thanks Smiriti for your input. Let me try one application on Mac machine. May be i will put few more question on your site.

  • Thanks alot for your reply Smriti. Now simulator works fine with eclipse. Now my problem is how to run my scripts using real device.(IOS)
    Can you please tell what are the things need to follow to connect to a device.Also can you put One example code to run script using real device. Mainly What are the Capablities need to set in the code.

  • Hi,

    I have followed all the steps in your tutorial but i am getting error popup after this step –

    Appium uses ‘Appium Inspector’ to view the elements similar to what we have as ‘uiautomatorviewer’ tool to view UI components in Android in UI Automator. Here , you can access elements using name, xpath or tagName as visible through appium inspector. Appium Inspector can be launched by clicking on the blue ‘i’ button besides launch button from appium app.

    Error –
    Could Not Launch Appium Inspector
    Could not start a new session

    Be sure the Appium server is running with an application opened by using the “App Path” parameter in Appium.app (along with package and activity for Android) or by connecting with selenium client and supplying this in the desired capabilities object.

    • Can you post your code here for desired capabilities object and also snapshot of the appium app where you are getting this error. Just make sure you are providing right ‘.app’ path.
      If you are running on simulator -> quit appium and also reset your simulator and try launching again.

  • Hi Smiriti,

    Thanks for quick reply below is the code but i am getting error on click of ‘i’ button.

    Please let me know how i can attach the screenshot in your blog –
    Appium Command Line Text –

    info: Welcome to Appium v0.17.6 (REV 7b32947e166a4338047f31ac14457c2b0eb432aa)

    info: Appium REST http interface listener started on 127.0.0.1:4723
    info – socket.io started

    info: Non-default server args: {“app”:”/Users/jitendrakumar/Desktop/Helath4MeApp/ConsumerTransparency.app”,”address”:”127.0.0.1″,”keepArtifacts”:true,”merciful”:true,”deviceName”:”iPhone”}

    Error Message
    Could Not Launch Appium Inspector
    Could not start a new session

    Be sure the Appium server is running with an application opened by using the “App Path” parameter in Appium.app (along with package and activity for Android) or by connecting with selenium client and supplying this in the desired capabilities object.

    File appDir = new File(“/Users/jitendrakumar/Desktop/Helath4MeApp”);

    File app = new File(appDir, “ConsumerTransparency.app”);

    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);
    capabilities.setCapability(“device”, “iPhone Simulator”);

    capabilities.setCapability(CapabilityType.VERSION, “7.1”);

    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);

    capabilities.setCapability(“app”, app.getAbsolutePath());
    System.out.println(“app launched 1”);

    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”),capabilities);

    System.out.println(“app launched”);

    • Could you make sure that ‘Prelaunch Application’ option is checked in Appium. ( Appium -> Preferences -> pre-launch application).Try quitting app again and then restart.
      Is your app designed for iOS7 only?

  • HI Smirti,

    If i am enabling the Prelaunch Application I am getting different error and my app is not designed only for iOS7 it can run on other iOS as well. Below is log if i enable the Prelaunch Application –

    info: [INST STDERR] Instruments Usage Error : Unknown hardware device specified: iPhone (3.5-inch) – Simulator – iOS 7.1

    info: [INST] Known Devices:

    info: [INST] Jitendra Kumar’s MacBook Pro (com.apple.instruments.devices.local)
    iPhone – Simulator – iOS 7.1
    iPhone Retina (3.5-inch) – Simulator – iOS 7.1
    iPhone Retina (4-inch) – Simulator – iOS 7.1
    iPhone Retina (4-inch 64-bit) – Simulator – iOS 7.1

    info: [INST] iPad – Simulator – iOS 7.1
    iPad Retina – Simulator – iOS 7.1
    iPad Retina (64-bit) – Simulator – iOS 7.1

    info: [INSTSERVER] Instruments exited with code 255

    error: Instruments crashed on startup

    info: Killall instruments

    debug: Sending command to instruments: au.bundleId()

    info: Stopping iOS log capture
    info: Killing the simulator process
    info: Instruments launched. Starting poll loop for new commands.
    info: Pushing command to appium work queue: “au.bundleId()”
    info: Killing any other simulator daemons

    info: Cleaning app state.

    info: No folders found to remove

    error: Could not pre-launch appium: Error: Instruments crashed on startup

    • That error usually means that your app is not compiled for the simulator. Which simulator are you using to run and is your app designed for iOS 7 only?
      I used iPhone Retina(4-inch 64-bit/iOS 7.1) and it worked fine.

  • i am also using iPhone Retina(4-inch 64-bit/iOS 7.1) and my app is not designed only for iOS7. In Simulator app is working fine.

  • Hi Smriti,

    I am very Happy after reading this post. I passed many days in exploring about appium and running test scripts from many sites and Appium-Discussion group. Although it was helping me,but response time was very slow. You really wrote a good post.

    I want to know the answers for the following questions:
    1) if i can write my test scripts in Ecllipse with java while my application is written in Objective-C?
    2) How test report can be generated for my tests?
    Waiting for your reply,please reply ASAP !!

    Thanks,
    Meenal

    • Hey Meenal
      Please find my answers below for your questions asked earlier –

      [1] Yes , scripts can be written in Java using eclipse while app is in Objective C.
      [2] You can use TestNG for report generation.
      [3] You can use same scripts as generated in Appium inspector but you can apply Aseertion methods for test cases failure/success check. One such example you can refer here from my github example.

      And regarding your Maven error :
      Try
      mvn clean install

      Also refer here where you can find more suggestions to fix error.

  • Also,Can i not use the scripts as same as generated in Appium Inspector during recording? OR these need to be modified in some way?
    If yes, Why and How?

    Thanks,
    Meenal

  • Hi Smriti,

    I’m getting following error when building as Maven Build my project:
    SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 0.254s
    [INFO] Finished at: Mon Mar 31 11:17:23 IST 2014
    [INFO] Final Memory: 4M/78M
    [INFO] ————————————————————————
    [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-site, site, post-site, site-deploy, pre-clean, clean, post-clean. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

    Can you please help me on this?

    Thanks,
    Meenal

  • Hey Smriti,

    The above issue resolved when i added a default goal in POM file. Now there is an another issue as under:

    SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [INFO] Scanning for projects…
    [INFO]
    [INFO] ————————————————————————
    [INFO] Building Jain 0.0.1-SNAPSHOT
    [INFO] ————————————————————————
    [INFO]
    [INFO] — maven-resources-plugin:2.5:resources (default-resources) @ Jain —
    [debug] execute contextualize
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/main/resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ Jain —
    [INFO] Compiling 2 source files to /Users/Jain/Documents/Jain/target/classes
    [INFO]
    [INFO] — maven-resources-plugin:2.5:testResources (default-testResources) @ Jain —
    [debug] execute contextualize
    [INFO] Using ‘UTF-8’ encoding to copy filtered resources.
    [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/test/resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Jain —
    [INFO] Compiling 1 source file to /Users/Jain/Documents/Jain/target/test-classes
    [INFO] ————————————————————-
    [ERROR] COMPILATION ERROR :
    [INFO] ————————————————————-
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[3,23] error: package org.junit does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[3,0] error: static import only from classes and interfaces
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[8,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[9,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[10,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[11,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[12,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[13,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[18,8] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[23,1] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[52,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[52,42] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[53,30] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[54,30] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[55,30] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[58,16] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[72,2] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[72,39] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[74,11] error: package org.junit does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[88,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[88,48] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[95,22] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[99,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[99,48] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[107,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[107,51] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[114,22] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[130,28] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[137,22] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[158,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[158,43] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[163,22] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[176,3] error: cannot find symbol
    [ERROR] class AppTest
    /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[176,40] error: cannot find symbol
    [INFO] 34 errors
    [INFO] ————————————————————-
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 4.213s
    [INFO] Finished at: Mon Mar 31 11:45:28 IST 2014
    [INFO] Final Memory: 14M/114M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile (default-testCompile) on project Jain: Compilation failure: Compilation failure:
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[3,23] error: package org.junit does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[3,0] error: static import only from classes and interfaces
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[8,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[9,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[10,26] error: package org.openqa.selenium does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[11,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[12,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[13,33] error: package org.openqa.selenium.remote does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[18,8] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[23,1] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[52,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[52,42] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[53,30] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[54,30] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[55,30] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[58,16] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[72,2] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[72,39] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[74,11] error: package org.junit does not exist
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[88,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[88,48] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[95,22] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[99,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[99,48] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[107,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[107,51] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[114,22] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[130,28] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[137,22] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[158,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[158,43] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[163,22] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[176,3] error: cannot find symbol
    [ERROR] class AppTest
    [ERROR] /Users/Jain/Documents/Jain/src/test/java/Meenal/Jain/AppTest.java:[176,40] error: cannot find symbol
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    Please respond me on this ASAP.

    Thanks,
    Meenal

    • Looks like you aren’t importing the libraries. Did you add selenium jar files and JUnit library required for the project?

      [1] Download Selenium Server (formerly the Selenium RC Server) version and Required client driver (according to your language choice) under – Selenium Client & WebDriver Language Bindings from here

      [2] Open your project properties -> import these jar files and apply.

      [3] Also import JUnit library in your project.

      • Hey Smriti,

        Thank you so much for your help!!
        I’m now able to run my tests.But I’m getting NULL pointer exception and build is getting failed. Can you please look into the issue:

        Running Meenal.Jain.AppTest
        Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.284 sec <<< FAILURE!
        subscribeTest(Meenal.Jain.AppTest) Time elapsed: 0.055 sec << [Help 1]
        [ERROR]
        [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
        [ERROR] Re-run Maven using the -X switch to enable full debug logging.
        [ERROR]
        [ERROR] For more information about the errors and possible solutions, please read the following articles:
        [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

        The error is on line:
        WebElement menu = driver.findElement(By.name(“Sign In”));
        I’ve also tried using XPath as follows:
        driver.findElement(By.xpath(“//window[1]/button[1]”)).click();

        but it didn’t solve the issue. Even appium is generating this script,but What can be the problem in eclipse to execute this.

        Please help.:)
        -Meenal

        • Better put the element check in try-catch block and see what it prints like say for element with xpath – “//window[1]/button[1]” as in your case. Also you can use ‘wait until ExpectedConditions’ check like –

          try {

          //keep checking for 5 sec if menu element to be clicked is
          found on the screen

          WebElement menu = (new WebDriverWait(driver, 5)).
          until(ExpectedConditions.elementToBeClickable
          (By.xpath("//window[1]/button[1]")));

          if (menu != null) {
          System.out.println("Menu found");
          menu.click();
          Thread.sleep(5000); //delay for 5 sec after menu is clicked
          }

          } catch (TimeoutException e) {
          System.out.println("Menu not found");
          }

          What this will do is – It will wait for 5 sec and keep checking within that 5 sec for that menu element. If then found -> it will print ‘Menu found’ and click on it otherwise will come in catch and just print ‘Menu not found’.

          Thread.sleep(time in ms) can be used to provide delay as providing proper delay is an important factor in automation.

          • I’m getting this exception even after keeping it in try-catch block. One more thing i’ve noticed this error is for all the elements i tried to access either it is a button or an image or anything else.

            This is my TestClass. Please have a look if i’m missing anything in this that is causing such problems:

            package Meenal.Jain;

            import java.io.File;
            import java.net.MalformedURLException;
            import java.net.URL;
            import org.junit.Test;
            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.openqa.selenium.support.ui.ExpectedConditions;
            import org.openqa.selenium.support.ui.WebDriverWait;

            public class AppTest {

            public WebDriver driver = null;
            int serial_no = 0;
            String appName = “App_iOS”;
            public static int testcases_passed = 0;
            public static int testcases_failed = 0;
            WebElement url;

            public static void main(String[] args) throws MalformedURLException,
            InterruptedException {

            AppTest testcases = new AppTest();

            // set up appium and launch app
            testcases.setUp();

            }

            public void setUp() {

            try {

            System.out.println(“Launching App”);
            String username;
            String key;
            // 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(“device”, “iPad”);
            File appDir = new File( “/Users/Jain/Desktop/AppFiles”);

            File app = new File(appDir,”greenfence.app”);
            //tell Appium where the location of the app is
            capabilities.setCapability(“app”, app.getAbsolutePath());

            username = “meenaljain”;
            key = “c6465ec4-4a3b-4793-a77a-2d0e85d8ada0”;
            driver = new RemoteWebDriver(new URL(“http://” + username + “:” + key + “@127.0.0.1:4723/wd/hub”), capabilities);
            System.out.println(“App launched”);
            Thread.sleep(5000);

            } catch (Exception e) {
            System.out.println(“App launch fail”);
            }
            }

            @Test
            public void login() throws InterruptedException {
            System.out.println(“App launched with image before getting exception”);
            //keep checking for 5 sec if menu element to be clicked is found on the screen
            WebElement menu = (new WebDriverWait(driver, 5)).until(ExpectedConditions.elementToBeClickable(By.xpath(“//window[1]/button[1]”)));

            if (menu != null) {
            System.out.println(“Menu Found”);
            menu.click();
            Thread.sleep(5000); //delay for 5 sec after menu is clicked
            }
            }

            }

          • Line no 85 is webdriver menu declaration line?
            Put separate try catch for menu element check the way I had stated in my previous comment and is app launched when you run this? If yes – where is it printing ‘App launched’?

          • Line no. 85 was the line when i initialized webelement say “menu”.

            Now this is my Test class that i’ve modified with Try/Catch and some more things:

            package Meenal.Jain;

            import java.io.File;
            import java.net.MalformedURLException;
            import java.net.URL;

            import org.junit.Test;
            import org.openqa.selenium.By;
            import org.openqa.selenium.TimeoutException;
            //import org.openqa.selenium;
            import org.openqa.selenium.WebDriver;
            import org.openqa.selenium.WebElement;
            import org.openqa.selenium.remote.CapabilityType;
            //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.openqa.selenium.remote.DesiredCapabilities;
            import org.openqa.selenium.remote.RemoteWebDriver;
            import org.openqa.selenium.support.ui.ExpectedConditions;
            import org.openqa.selenium.support.ui.WebDriverWait;

            public class AppTest {

            public WebDriver driver = null;
            int serial_no = 0;
            String appName = “App_iOS”;
            public static int testcases_passed = 0;
            public static int testcases_failed = 0;
            WebElement url;

            public static void main(String[] args) throws MalformedURLException,
            InterruptedException {

            AppTest testcases = new AppTest();

            // set up appium and launch app
            testcases.setUp();

            }

            public void setUp() {

            try {

            System.out.println(“Launching App”);
            //String username;
            // String key;
            // 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(“device”, “iPad”);
            File appDir = new File( “/Users/Jain/Desktop/AppFiles”);

            File app = new File(appDir,”greenfence.app”);
            //tell Appium where the location of the app is
            capabilities.setCapability(“app”, app.getAbsolutePath());

            //username = “meenaljain”;
            //key = “c6465ec4-4a3b-4793-a77a-2d0e85d8ada0”;
            //driver = new RemoteWebDriver(new URL(“http://” + username + “:” + key + “@127.0.0.1:4723/wd/hub”), capabilities);
            driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
            System.out.println(“App launched”);
            Thread.sleep(5000);

            } catch (Exception e) {
            System.out.println(“App launch fail”);
            }
            }

            @Test
            public void login() throws InterruptedException {
            try {

            //keep checking for 5 sec if menu element to be clicked is found on the screen

            WebElement menu = (new WebDriverWait(driver, 5)).until(ExpectedConditions.elementToBeClickable(By.xpath(“//window[1]/button[1]”)));

            if (menu != null) {
            System.out.println(“Menu found”);
            menu.click();
            Thread.sleep(5000); //delay for 5 sec after menu is clicked
            }

            }
            catch (TimeoutException e) {
            System.out.println(“Menu not found”);
            }
            }

            }

            and this is the error log which is being generated in console:

            SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
            SLF4J: Defaulting to no-operation (NOP) logger implementation
            SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
            [INFO] Scanning for projects…
            [INFO]
            [INFO] ————————————————————————
            [INFO] Building sauce_quickstart 0.0.1
            [INFO] ————————————————————————
            [INFO]
            [INFO] — maven-resources-plugin:2.5:resources (default-resources) @ Jain —
            [debug] execute contextualize
            [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
            [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/main/resources
            [INFO]
            [INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ Jain —
            [INFO] Nothing to compile – all classes are up to date
            [INFO]
            [INFO] — maven-resources-plugin:2.5:testResources (default-testResources) @ Jain —
            [debug] execute contextualize
            [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
            [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/test/resources
            [INFO]
            [INFO] — maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Jain —
            [INFO] Nothing to compile – all classes are up to date
            [INFO]
            [INFO] — maven-surefire-plugin:2.14:test (default-test) @ Jain —
            [INFO] Surefire report directory: /Users/Jain/Documents/Jain/target/surefire-reports

            ——————————————————-
            T E S T S
            ——————————————————-
            Running Meenal.Jain.AppTest
            Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.256 sec <<< FAILURE!
            login(Meenal.Jain.AppTest) Time elapsed: 0.064 sec <<< ERROR!
            java.lang.NullPointerException: null
            at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
            at org.openqa.selenium.support.ui.FluentWait.(FluentWait.java:94)
            at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:66)
            at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:40)
            at Meenal.Jain.AppTest.login(AppTest.java:83)

            Results :

            Tests in error:
            AppTest.login:83 ? NullPointer

            Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

            [INFO] ————————————————————————
            [INFO] BUILD FAILURE
            [INFO] ————————————————————————
            [INFO] Total time: 5.623s
            [INFO] Finished at: Tue Apr 01 12:26:41 GMT+05:30 2014
            [INFO] Final Memory: 6M/81M
            [INFO] ————————————————————————
            [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project Jain: There are test failures.
            [ERROR]
            [ERROR] Please refer to /Users/Jain/Documents/Jain/target/surefire-reports for the individual test results.
            [ERROR] -> [Help 1]
            [ERROR]
            [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
            [ERROR] Re-run Maven using the -X switch to enable full debug logging.
            [ERROR]
            [ERROR] For more information about the errors and possible solutions, please read the following articles:
            [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

            I know i’m unintentionally frustrating you,but this is my first time with test automation,so i don’t know anyhing about it,so please don’t mind.
            I really appreciate your cooperation 🙂

          • I’m using following version of Eclipse:
            Version: Kepler Service Release 1
            Build id: 20130919-0819

          • Install maven externally and run maven from console and switch to that as given in the first answer in that stack overflow link attached in my previous comment

          • Hey Smriti,

            I’ve installed maven externally and using that in my eclipse.
            Also I’ve run test using mvn test for my project from command line,but in that case also same error is generating.
            I’m not finding anything helpful on this.
            Other sample projects are running fine via both eclipse and command line.

            Is there anything specific i need to add for iOS app? Can you please see my code again?

            Thanks,
            Meenal

          • Hello Smriti,

            Finally i found the root cause of the problem. Actually it is executing Catch block of Setup method everytime,not the Try block thats why driver is not being initialized and NULL pointer exception is there for each webelement.

            Can you please help me on this,What may be the reason and possible solutions for this?

            Thanks,
            Meenal

  • Hi Smirti,

    I am able to run the single test case with web driver and TestNG in appium for iOS. Once i am adding another test case in same script(in single file with two @Test annotation) appium throws an exception Unable to start new session. Even i tried to create the test suit that is also not working. How we can write and run multiple test case using TestNG and webDriver for appium.Have you tried?

    • This is the error log in console:

      SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
      SLF4J: Defaulting to no-operation (NOP) logger implementation
      SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
      [INFO] Scanning for projects…
      [INFO]
      [INFO] ————————————————————————
      [INFO] Building sauce_quickstart 0.0.1
      [INFO] ————————————————————————
      [INFO]
      [INFO] — maven-resources-plugin:2.5:resources (default-resources) @ Jain —
      [debug] execute contextualize
      [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/main/resources
      [INFO]
      [INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ Jain —
      [INFO] Nothing to compile – all classes are up to date
      [INFO]
      [INFO] — maven-resources-plugin:2.5:testResources (default-testResources) @ Jain —
      [debug] execute contextualize
      [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
      [INFO] skip non existing resourceDirectory /Users/Jain/Documents/Jain/src/test/resources
      [INFO]
      [INFO] — maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Jain —
      [INFO] Nothing to compile – all classes are up to date
      [INFO]
      [INFO] — maven-surefire-plugin:2.14:test (default-test) @ Jain —
      [INFO] Surefire report directory: /Users/Jain/Documents/Jain/target/surefire-reports

      ——————————————————-
      T E S T S
      ——————————————————-
      Running Meenal.Jain.AppTest
      App launched with image before getting exception
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.347 sec <<< FAILURE!
      login(Meenal.Jain.AppTest) Time elapsed: 0.07 sec <<< ERROR!
      java.lang.NullPointerException: null
      at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
      at org.openqa.selenium.support.ui.FluentWait.(FluentWait.java:94)
      at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:66)
      at org.openqa.selenium.support.ui.WebDriverWait.(WebDriverWait.java:40)
      at Meenal.Jain.AppTest.login(AppTest.java:85)

      Results :

      Tests in error:
      AppTest.login:85 ? NullPointer

      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

      [INFO] ————————————————————————
      [INFO] BUILD FAILURE
      [INFO] ————————————————————————
      [INFO] Total time: 6.850s
      [INFO] Finished at: Tue Apr 01 11:52:12 GMT+05:30 2014
      [INFO] Final Memory: 6M/81M
      [INFO] ————————————————————————
      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project Jain: There are test failures.
      [ERROR]
      [ERROR] Please refer to /Users/Jain/Documents/Jain/target/surefire-reports for the individual test results.
      [ERROR] -> [Help 1]
      [ERROR]
      [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
      [ERROR] Re-run Maven using the -X switch to enable full debug logging.
      [ERROR]
      [ERROR] For more information about the errors and possible solutions, please read the following articles:
      [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    • Can you post here your code?
      What have you mentioned in @BeforeMethod , @BeforeTest ?

      For example :

      @BeforeTest
      System.out.println(“Setting up Appium”);

      @BeforeMethod
      System.out.println(“Starting test case”);

      @Test
      a();

      @Test
      b();

      @AfterMethod
      System.out.println(“Test case done”);

      @AfterTest
      System.out.println(“Everything executed”);

      So first @BeforeTest will be called.
      Then it will execute parallel as –
      @BeforeMethod
      a();
      @AfterMethod

      and
      @BeforeMethod
      b();
      @AfterMethod

      And at last @AfterTest will be called.

      What TestNG does is – It will find all the methods marked as @Test. After this, it will create two parallel threads, and will start executing each method in its own thread. Before and after each @Test, @BeforeMethod and @AfterMethod are executed in each thread.

      Refer this in case of any doubts – http://www.deepshiftlabs.com/sel_blog/?p=1932&&lang=en-us

      • Hi Smriti,

        This is my code:

        package Meenal.Jain;

        import java.io.File;
        import java.net.MalformedURLException;
        import java.net.URL;

        import org.junit.Test;
        import org.openqa.selenium.By;
        import org.openqa.selenium.TimeoutException;
        //import org.openqa.selenium;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.WebElement;
        import org.openqa.selenium.remote.CapabilityType;
        //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.openqa.selenium.remote.DesiredCapabilities;
        import org.openqa.selenium.remote.RemoteWebDriver;
        import org.openqa.selenium.support.ui.ExpectedConditions;
        import org.openqa.selenium.support.ui.WebDriverWait;
        import static junit.framework.Assert.assertEquals;
        import org.junit.After;
        import org.junit.Before;
        import java.net.MalformedURLException;
        public class AppTest {

        private WebDriver driver;
        int serial_no = 0;
        String appName = “App_iOS”;
        public static int testcases_passed = 0;
        public static int testcases_failed = 0;
        WebElement url;

        public static void main(String[] args) throws MalformedURLException,
        InterruptedException {

        AppTest testcases = new AppTest();

        // set up appium and launch app
        testcases.setUp();

        }

        @Before
        public void setUp() throws MalformedURLException {

        try {

        System.out.println(“Launching App”);
        System.setProperty(“org.apache.commons.logging.Log”, “org.apache.commons.logging.impl.Jdk14Logger”);
        // 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(“device”, “iPad”);
        File appDir = new File( “/Users/Jain/Desktop/AppFiles”);

        File app = new File(appDir,”greenfence.app”);
        //tell Appium where the location of the app is
        capabilities.setCapability(“app”, app.getAbsolutePath());

        // String username= “meenaljain”;
        // String key = “c6465ec4-4a3b-4793-a77a-2d0e85d8ada0”;
        // driver = new RemoteWebDriver(new URL(“http://” + username + “:” + key + “@127.0.0.1:4723/wd/hub”), capabilities);
        //driver = new RemoteWebDriver(new URL(“http://meenaljain:c6465ec4-4a3b-4793-a77a-2d0e85d8ada0@ondemand.saucelabs.com:80/wd/hub”),capabilities);
        driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
        System.out.println(“App launched”);
        //Thread.sleep(5000);

        } catch (MalformedURLException e) {
        System.out.println(“App launch fail”);
        e.printStackTrace();
        }
        }

        @Test
        public void login() throws InterruptedException {
        // try {
        // //keep checking for 5 sec if menu element to be clicked is found on the screen
        //
        // WebElement menu = (new WebDriverWait(driver, 5)).until(ExpectedConditions.elementToBeClickable(By.xpath(“//window[1]/button[1]”)));
        //
        // if (menu != null) {
        // System.out.println(“Menu found”);
        // menu.click();
        // Thread.sleep(5000); //delay for 5 sec after menu is clicked
        // }
        //
        // }
        // catch (TimeoutException e) {
        // System.out.println(“Menu not found”);
        // }

        driver.get(“http://www.amazon.com/”);
        assertEquals(“Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more”, driver.getTitle());
        }

        // @Test
        // public void logout() throws InterruptedException {
        // try {
        // //keep checking for 5 sec if menu element to be clicked is found on the screen
        //
        // WebElement menu = driver.findElement(By.name(“Sign In”));
        // if (menu != null) {
        // System.out.println(“Menu found”);
        // menu.click();
        // Thread.sleep(5000); //delay for 5 sec after menu is clicked
        // }
        //
        // }
        // catch (TimeoutException e) {
        // System.out.println(“Menu not found”);
        // }
        // }
        //
        @After
        public void tearDown() throws Exception {
        driver.quit();
        }

        }

  • This is the exception when initializing webdriver: unhandled exception type malformedurlexception url
    on this line: driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    Any suggessions?

    • Add import java.net.MalformedURLException; and modify setUp method :
      public void setUp() throws MalformedURLException
      Also catch exception like :
      catch (MalformedURLException e) {
      e.printStackTrace();
      }

      • well,your solution worked and it resolved MalformedURLException. Now What error i’m getting in console are as under:

        Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 3.525 sec <<< FAILURE!
        login(Meenal.Jain.AppTest) Time elapsed: 3.284 sec <<< ERROR!

        org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
        Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26'
        System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'
        Driver info: driver.version: RemoteWebDriver
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:382)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:241)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:228)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:431)
        at java.net.Socket.connect(Socket.java:527)
        at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
        at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
        at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
        at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
        at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
        at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
        at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
        at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:316)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:295)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:216)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:111)
        at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:129)
        at Meenal.Jain.AppTest.setUp(AppTest.java:71)

        login(Meenal.Jain.AppTest) Time elapsed: 3.285 sec <<< ERROR!
        java.lang.NullPointerException: null
        at Meenal.Jain.AppTest.tearDown(AppTest.java:123)

        Results :

        Tests in error:
        AppTest.setUp:71 ? UnreachableBrowser Could not start a new session. Possible …
        AppTest.tearDown:123 NullPointer

        Tests run: 2, Failures: 0, Errors: 2, Skipped: 0

        [INFO] ————————————————————————
        [INFO] BUILD FAILURE
        [INFO] ————————————————————————
        [INFO] Total time: 14.035 s
        [INFO] Finished at: 2014-04-01T16:46:50+05:30
        [INFO] Final Memory: 6M/81M
        [INFO] ————————————————————————
        [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.14:test (default-test) on project Jain: There are test failures.

        CODE for initializing webdriver is:

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
        capabilities.setCapability(CapabilityType.VERSION, "6.1");
        capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
        capabilities.setCapability("device", "iPad");
        File appDir = new File( "/Users/Jain/Desktop/AppFiles");

        File app = new File(appDir,"greenfence.app");
        //tell Appium where the location of the app is
        capabilities.setCapability("app", app.getAbsolutePath());
        driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub&quot;), capabilities);

  • Hi Smriti

    After sorting out many of the issue,now i’m getting following error:
    org.openqa.selenium.WebDriverException: Sauce could not start your job. For more information on what happened, please visit https://saucelabs.com/jobs/31e72b9c35764a569492e5ae71472826 (WARNING: The server did not provide any stacktrace information)

    and then i visited above link i found following message:

    Failed to download mobile app: /Users/Jain/Desktop/AppFiles/greenfence.app error

    Can you please tell me where i’m doing wrong?

    Thanks,
    Meenal

  • Hi Smriti,

    when i’m running my tests on sauce,i’m getting following error log in consloe:

    [INFO] Scanning for projects…
    [INFO]
    [INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
    [INFO]
    [INFO] ————————————————————————
    [INFO] Building sauce_quickstart 0.0.1
    [INFO] ————————————————————————
    [INFO]
    [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ Jain —
    [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory /Users/Jain/Documents/appium/src/main/resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3.2:compile (default-compile) @ Jain —
    [WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!
    [INFO] Compiling 1 source file to /Users/Jain/Documents/appium/target/classes
    [INFO]
    [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ Jain —
    [WARNING] Using platform encoding (US-ASCII actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory /Users/Jain/Documents/appium/src/test/resources
    [INFO]
    [INFO] — maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ Jain —
    [WARNING] File encoding has not been set, using platform encoding US-ASCII, i.e. build is platform dependent!
    [INFO] Compiling 1 source file to /Users/Jain/Documents/appium/target/test-classes
    [INFO]
    [INFO] — maven-surefire-plugin:2.14:test (default-test) @ Jain —
    [INFO] Surefire report directory: /Users/Jain/Documents/appium/target/surefire-reports

    ——————————————————-
    T E S T S
    ——————————————————-
    Running sauce.appium.AppTest
    test: logout
    Launching App
    runOnSauce=falseApr 2, 2014 11:32:22 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies
    WARNING: Invalid cookie header: “Set-Cookie: csrf_token=483b3699443969e563cf5436bc85e875; expires=”Wed, 02-Apr-2014 06:12:21 GMT”; Max-Age=600; Path=/”. Unable to parse expires attribute: “Wed, 02-Apr-2014 06:12:21 GMT”
    Test running on Sauce
    SauceOnDemandSessionID=adcdc3dd2e184cd6913601ff13848476 job-name=sauce.appium.AppTest.logout
    Apr 2, 2014 11:40:13 AM com.saucelabs.saucerest.SauceREST updateJobInfo
    WARNING: Error closing result stream
    java.io.IOException: Server returned HTTP response code: 401 for URL: https://saucelabs.com/rest/v1/null/jobs/adcdc3dd2e184cd6913601ff13848476
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1459)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
    at com.saucelabs.saucerest.SauceREST.updateJobInfo(SauceREST.java:205)
    at com.saucelabs.junit.SauceOnDemandTestWatcher.failed(SauceOnDemandTestWatcher.java:122)
    at org.junit.rules.TestWatcher.failedQuietly(TestWatcher.java:84)
    at org.junit.rules.TestWatcher.access$300(TestWatcher.java:46)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:62)
    at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)
    Job link: https://saucelabs.com/jobs/adcdc3dd2e184cd6913601ff13848476?auth=ee792e96819ce44e0139aa70c390601e
    sauce link: https://saucelabs.com/tests/adcdc3dd2e184cd6913601ff13848476
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 480.172 sec <<< FAILURE!
    logout(sauce.appium.AppTest) Time elapsed: 480.022 sec <<< ERROR!
    org.openqa.selenium.UnsupportedCommandException: {"status": 6, "sessionId": "adcdc3dd2e184cd6913601ff13848476", "value": ""}
    Command duration or timeout: 303.44 seconds
    Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0', time: '2013-02-27 13:51:26'
    System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.9.1', java.version: '1.6.0_65'
    Session ID: adcdc3dd2e184cd6913601ff13848476
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    Capabilities [{platform=MAC, javascriptEnabled=true, hasMetadata=true, browserName=ios, desired={browserName=ios, device=iPad Simulator, webdriver.remote.quietExceptions=true}, locationContextEnabled=false, version=6.1, databaseEnabled=false, webStorageEnabled=false, device=iPad Simulator, webdriver.remote.quietExceptions=true, warnings={}, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:307)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:380)
    at org.openqa.selenium.By$ByName.findElement(By.java:292)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:299)
    at sauce.appium.AppTest.logout(AppTest.java:307)

    Results :

    Tests in error:
    AppTest.logout:307 ? UnsupportedCommand {"status": 6, "sessionId": "adcdc3dd2e…

    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————

    I read the tutorial the link you provided for.I've done all the required things as well.
    Please look into my code and let me know what is causing this error and how can i resolve it:

    public class AppTest implements SauceOnDemandSessionIdProvider {

    private WebDriver driver;

    /** Page object references. Allows using ‘home’ instead of ‘HomePage’ **/
    protected HomePage home;

    /** wait wraps Helpers.wait **/
    // public static WebElement wait(By locator) {
    // return Helpers.wait(locator);
    // }

    private boolean runOnSauce = System.getProperty(“sauce”) != null;

    /** Authenticate to Sauce with environment variables SAUCE_USER_NAME and SAUCE_API_KEY **/
    private SauceOnDemandAuthentication auth = new SauceOnDemandAuthentication(
    “meenaljain”, “c6465ec4-4a3b-4793-a77a-2d0e85d8ada0″);

    /** Report pass/fail to Sauce Labs **/
    public @Rule
    SauceOnDemandTestWatcher reportToSauce = new SauceOnDemandTestWatcher(this, auth);

    private String sessionId;

    /** Keep the same date prefix to identify job sets. **/
    private static final Date date = new Date();

    @Rule
    public TestRule printTests = new TestWatcher() {
    protected void starting(Description description) {
    System.out.println(” test: ” + description.getMethodName());
    }

    protected void finished(Description description) {
    final String session = getSessionId();

    if (session != null) {
    System.out.println(” sauce link: ” + “https://saucelabs.com/tests/” + session);
    }
    }
    };

    /** Run before each test **/
    @Before
    public void setUp() throws Exception {

    System.out.println(“Launching App”);
    System.setProperty(“org.apache.commons.logging.Log”, “org.apache.commons.logging.impl.Jdk14Logger”);
    // 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(“device”, “iPad Simulator”);
    capabilities.setCapability(“device-orientation”, “landscape”);

    File appDir = new File( “/Users/Jain/Desktop/AppFiles”);
    File app = new File(appDir,”greenfence.app”);
    //tell Appium where the location of the app is
    capabilities.setCapability(“app”, app.getAbsolutePath());
    // Set job name on Sauce Labs
    capabilities.setCapability(“name”, “Greenfence automation Demo ” + date);
    String userDir = System.getProperty(“user.dir”);
    System.out.printf(“runOnSauce=%s”,runOnSauce);
    runOnSauce = true;
    if (runOnSauce) {
    String user = auth.getUsername();
    String key = auth.getAccessKey();

    // Upload app to Sauce Labs
    SauceREST rest = new SauceREST(user, key);
    String localApp = “greenfence.app.zip”;
    rest.uploadFile(new File(userDir, localApp), localApp);

    capabilities.setCapability(“app”, “sauce-storage:” + localApp);
    URL sauceURL = new URL(“http://” + user + “:” + key + “@ondemand.saucelabs.com:80/wd/hub”);
    driver = new RemoteWebDriver(sauceURL, capabilities);
    this.sessionId = ((RemoteWebDriver)driver).getSessionId().toString();
    System.out.println(“Test running on Sauce”);

    } else {
    appDir = new File( “/Users/Jain/Desktop/AppFiles”);
    app = new File(appDir,”greenfence.app”);
    capabilities.setCapability(“app”, app.getAbsolutePath());

    // String appPath = Paths.get(userDir, “greenfence.app”).toAbsolutePath().toString();
    // capabilities.setCapability(“app”, appPath);
    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
    System.out.println(“Test running on Local in appium”);

    }

    sessionId = ((RemoteWebDriver) driver).getSessionId().toString();

    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    // Helpers.init(driver);
    }

    /** Run after each test **/
    @After
    public void tearDown() throws Exception {
    if (driver != null) driver.quit();
    }

    /** If we’re not on Sauce then return null otherwise SauceOnDemandTestWatcher will error. **/
    public String getSessionId() {
    return runOnSauce ? sessionId : null;
    }

    @Test
    public void logout() throws InterruptedException {
    try {
    //keep checking for 5 sec if menu element to be clicked is found on the screen

    WebElement menu = driver.findElement(By.name(“Sign In”));
    if (menu != null) {
    System.out.println(“Menu found”);
    menu.click();
    Thread.sleep(5000); //delay for 5 sec after menu is clicked
    }

    }
    catch (TimeoutException e) {
    System.out.println(“Menu not found”);
    }
    }
    }

    runOnsauce variable i’m getting is always ‘false’ thats why i manually changed it to true to run my tests on sauce.

  • These are the commands response on sauce labs:

    POST timeouts/implicit_wait
    37s (+0.01s)

    ms: 30000

    => null
    POST element
    37s (+4m 59.99s)

    using: “name”
    value: “Sign In”

    => “ERROR user closed connection while waiting for command to complete”
    POST element
    5m 40s (+0.01s)

    using: “name”
    value: “Sign In”

    => “”
    DELETE
    5m 41s (+0s)

    => “”

      • Hey Smriti,

        I want to run my tests on sauce labs because it’ll be very easy to track all my previous tests anytime and i can see test report,screenshots and video for all the tests here. So i’ll be continuing on working this.
        Anyways,Your guide was very helpful for me to come upto here.
        Thank you so much for all your help.

        Thanks & Regards,
        Meenal

  • I am able to run the single test case with web driver and TestNG in appium for iOS. Once i am adding another test case in same script(in single file with two @Test annotation) appium throws an exception Unable to start new session. Even i tried to create the test suit that is also not working. How we can write and run multiple test case using TestNG and webDriver for appium.Have you tried?

    • Can you post here your code?
      What have you mentioned in @BeforeMethod , @BeforeTest ?

      For example :

      @BeforeTest
      System.out.println(“Setting up Appium”);

      @BeforeMethod
      System.out.println(“Starting test case”);

      @Test
      a();

      @Test
      b();

      @AfterMethod
      System.out.println(“Test case done”);

      @AfterTest
      System.out.println(“Everything executed”);

      So first @BeforeTest will be called.
      Then it will execute parallel as –
      @BeforeMethod
      a();
      @AfterMethod

      and
      @BeforeMethod
      b();
      @AfterMethod

      And at last @AfterTest will be called.

      What TestNG does is – It will find all the methods marked as @Test. After this, it will create two parallel threads, and will start executing each method in its own thread. Before and after each @Test, @BeforeMethod and @AfterMethod are executed in each thread.

      Refer this in case of any doubts – http://www.deepshiftlabs.com/sel_blog/?p=1932&&lang=en-us

  • @BeforeTest
    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(“device”, “iPhone Retina (4-inch 64-bit)”);
    capabilities.setCapability(“app”, “/Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app”);
    wd = new RemoteWebDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
    wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    }

    @BeforeMethod

    @Test
    public void testSecond() throws InterruptedException {
    wd.findElement(By.xpath(“//window[3]/alert[1]/tableview[1]/cell[1]”)).click();
    wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[2]”)).click();
    wd.findElement(By.name(“Back”)).click();

    }

    @Test
    public void testHome() throws InterruptedException {

    wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[5]”)).click();

    //wd.findElement(By.name(“Skip Login”)).click();
    wd.findElement(By.xpath(“//window[1]/button[2]”)).click();
    }

    @AfterMethod
    public void finish(){
    System.out.println(“Finish TC 3”);
    }

    @AfterTest
    public void tearDown() throws Exception {
    wd.quit();
    }

    Error – FAILED CONFIGURATION: @BeforeMethod testSecond
    org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.

    If i am runnig single TC then born tc are passed.

  • hey Smriti,

    I am trying automation 1st time and it is with appium. i did all the steps as u mentioned and i am able to launch appium server and able to identify all the elements but my confusion is how to write script in eclipse and how to run it using testng? please help me with steps. Thanks in advance 🙂

    • One sample code you can refer from my github link – here . This is without TestNG.

      To write with TestNG , you just need to import it’s library and write test cases using annotations like @Test , @BeforeMethod.
      For TestNG , refer here . You will find detailed explanation here starting with TestNG installation to writing tests.

  • Hey i am using ur sample code to launch my application in appium. but nothing is happening. Is anything wrong here? what should be the precondition before running the code in eclipse using TestNG? i am keeping appium on, simulator on with running app on it. Please suggest.

    public class AppiumTest {

    public WebDriver driver = null;
    public void setUp() {

    try {

    System.out.println(“Launching App”);

    // two ways to launch app :
    // you can set up appium in following manner – if you want to run on simulator
    File appDir = new File(
    “/Users/rajesh/Library/Application Support/iPhone Simulator/7.0/Applications/CD609D5D-4320-4A8C-99A2-E9AABCCFBF0F”); //iphoneSimulator is the folder where .app is located
    File app = new File(appDir, “App_iOS.app”);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);
    capabilities.setCapability(CapabilityType.VERSION, “7.0”);
    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);
    capabilities.setCapability(“app”, app.getAbsolutePath());
    driver = new RemoteWebDriver(
    new URL(“http://127.0.0.1:4722/wd/hub”), capabilities);

    System.out.println(“App launched”);

    } catch (Exception e) {
    System.out.println(“App launch fail”);

    }
    }
    }

  • Hi,
    I have crated two Test scripts using selenium web driver and Test NG but i am not able to run both test cases from test suite.

    TestSuite Code –

    First test execute successfully on second test i am getting exception.

    I am getting below exception –

    org.openqa.selenium.WebDriverException: A new session could not be created. (Original error: Requested a new session but one was in progress) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 15 milliseconds
    Build info: version: ‘2.21.0’, revision: ‘16552’, time: ‘2012-04-11 19:09:00’
    System info: os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.2’, java.version: ‘1.6.0_65’
    Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:175)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:459)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:140)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:95)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:103)
    at com.optumhealth.ehp.reg.Test2.setUp(Test2.java:43)
    … Removed 30 stack frames

    If i am override the existing session (Appium> Preferneces> Override existing session)then i am getting below exception –

    error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

    info: Cleaning up appium session
    info: Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:351:31)
    at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:294:12)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:797:12)
    info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments crashed on startup)”,”origValue”:”Instruments crashed on startup”},”sessionId”:null}

    POST /wd/hub/session 500 37911ms – 210b

  • Hi Smriti,

    I am trying to use C# for automating IOS native app via appium I am able to use appium Inspector easily but bit stuck after that. How can I create a sample test. Can you please help.

    Thanks,
    Nitin

  • Hi Smriti,

    when i’m running on real device it is giving me an error “Invalid device name specified: iPad”.
    I’m using following code:
    capabilities.setCapability(“device”, “iPad”);
    capabilities.setCapability(“udid”, “6d63f7d2296d8155da4b007a5e64559727b96b0e”);
    capabilities.setCapability(“bundleid”, “com.originate.enterprise.IBMS”);
    capabilities.setCapability(“ipa”, “App_iOS.ipa”);
    How can i resolve this?

  • Hi Smirithi,

    Do we have any possibility of testing inbuilt applications like Photos, Videos, Calendar on real device which are available in device. Since applications are not installed from our side, i don’t have capabilities or .app file for the same.

    Is their any way i can get capabilities for the applications which are already installed in the application to launch & test the same?

    is it not possible to use Appium in iOS with out .app file?

    Request you to answer ASAP, as i’m stuck in between.

    Regards,
    Yogeesh

      • Hi Smriti, If the developer provides me with a signed .ipa file of the app, will my app launch?
        My app launches and closes giving the error “The app needs to be signed with a development entity”
        If the developer signs it with his developer id and gives me the .ipa file, will my app launch? do i need a developer id myself and do i need to do anything extra.
        i only have the .ipa file and nothing else.
        It would be very helpful if you could help me out here!

        • Hey,
          Your .ipa should be built with a valid Development Distribution Certificate, and device should have provisioning profile (for real devices)
          This should be good enough to launch app.

  • Hi Smriti,

    I’m getting the following exception when I try to launch app. Can you please help me debug it?

    2014-04-07T09:12:27.028Z – error: Failed to start an Appium session, err was: Error: Instruments crashed on startup
    2014-04-07T09:12:27.030Z – info: Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/Users/klalam/.nvm/v0.10.21/lib/node_modules/appium/lib/devices/ios/instruments.js:339:31)
    at null. (/Users/klalam/.nvm/v0.10.21/lib/node_modules/appium/lib/devices/ios/instruments.js:290:12)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:789:12)
    2014-04-07T09:12:27.031Z – info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments crashed on startup)”,”origValue”:”Instruments crashed on startup”},”sessionId”:null}

    Thanks,
    Kiran.

  • Once I am getting error i can see below stack trace in appium –
    debug: Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: Pushing command to appium work queue: “au.getElementByXpath(‘\\/\\/window[3]\\/alert[1]\\/tableview[1]\\/cell[1]’)”

    info: [INSTSERVER] Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: [INSTSERVER] Socket data received (50 bytes)

    info: [INSTSERVER] Socket data being routed for ‘cmd’ event
    info: [INSTSERVER] Got result from instruments: {“status”:7,”value”:null}

    info: Pushing command to appium work queue: “au.getElementByXpath(‘\\/\\/window[3]\\/alert[1]\\/tableview[1]\\/cell[1]’)”

    debug: Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: [INSTSERVER] Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: [INSTSERVER] Socket data received (50 bytes)

    info: [INSTSERVER] Socket data being routed for ‘cmd’ event
    info: [INSTSERVER] Got result from instruments: {“status”:7,”value”:null}

    info: Pushing command to appium work queue: “au.getElementByXpath(‘\\/\\/window[3]\\/alert[1]\\/tableview[1]\\/cell[1]’)”

    debug: Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: [INSTSERVER] Sending command to instruments: au.getElementByXpath(‘\/\/window[3]\/alert[1]\/tableview[1]\/cell[1]’)

    info: [INSTSERVER] Socket data received (50 bytes)

    info: [INSTSERVER] Socket data being routed for ‘cmd’ event
    info: [INSTSERVER] Got result from instruments: {“status”:7,”value”:null}
    info: Responding to client with error: {“status”:7,”value”:{“message”:”An element could not be located on the page using the given search parameters.”},”sessionId”:”ec332a77-effb-4a1e-88f3-bfc8cdf7183c”}
    POST /wd/hub/session/ec332a77-effb-4a1e-88f3-bfc8cdf7183c/element 500 60018ms – 186b

    And Error in Eclipse –
    inside testSecond
    Finish testSecond
    inside testFirst
    Finish testFirst
    Finish After Method
    inside testSecond
    FAILED CONFIGURATION: @BeforeMethod testSecond
    org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 60.02 seconds
    For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
    Build info: version: ‘2.21.0’, revision: ‘16552’, time: ‘2012-04-11 19:09:00’
    System info: os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.2’, java.version: ‘1.6.0_65’
    Driver info: driver.version: RemoteWebDriver

    • Do one thing – make a method inside @BeforeMethod and print something there separately , the same way as you are doing for @AfterMethod.

      What is happening right now in your code is , the flow is like :
      @BeforeTest -> @BeforeMethod -> @Test -> @Test -> @AfterMethod -> @BeforeMethod -> @Test -> @Test -> @AfterMethod and so on. It will keep looping inside that.

      Because I think it is taking @Test inside that @BeforeMethod so it will never come out of it.
      You add a separate print statement inside @BeforeMethod and then flow should and will work like :

      @BeforeTest -> @BeforeMethod -> @Test -> @AfterMethod -> @BeforeMethod -> @Test -> @AfterMethod -> @AfterTest.

  • I have changed the code but still issue –

    //output of SOP

    inside m1
    inside testFirst
    Finish After Method
    inside m1
    inside testSecond
    Finish testSecond
    Finish After Method
    inside tear down
    PASSED: testSecond
    FAILED: testFirst

    @BeforeMethod

    public void m1(){
    System.out.println(“inside m1”);
    }
    @Test
    public void testSecond() throws InterruptedException {
    System.out.println(“inside testSecond”);
    wd.findElement(By.xpath(“//window[3]/alert[1]/tableview[1]/cell[1]”)).click();
    wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[5]”)).click();
    wd.findElement(By.xpath(“//window[1]/button[2]”)).click();
    System.out.println(“Finish testSecond”);
    Thread.sleep(10000);
    }

    @Test
    public void testFirst() throws InterruptedException {
    System.out.println(“inside testFirst”);
    wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[2]”)).click();
    wd.findElement(By.name(“Back”)).click();
    System.out.println(“Finish testFirst”);
    Thread.sleep(10000);
    }
    @AfterMethod
    public void finish(){
    System.out.println(“Finish After Method”);
    }

    @AfterTest
    public void tearDown() throws Exception {
    System.out.println(“inside tear down”);
    //wd.close();
    wd.quit();
    }

  • I just changed the sequences of test case and those are passed now..little surprised..but any way good news for me….Thanks a lot now i am going to try with XML..may be i will post few more question for you…but Really Appreciate your response.

  • Can you tell me one more thing..if we have 100 test cases then how we can write the test suite in selenium using appiumm..i tried the same approach as we are doing in web application. for example Write the single test script for each test flow and add each test script in testing.xml suite and run the suite. If i am following the same approach here then getting error Session could not be started….so i just want to know which approach i should follow to create the test suite…if my question is not clear to you i can explain more.

  • Hi Smirti,

    I have created two Test classes with name Test1 and Test2 and created a suite where i have added these two classes but i am unable to execute the test suite.I am getting below error in appium console.
    Test1.java
    public class Test1 implements UIConstants {
    public WebDriver wd = null;

    @BeforeTest
    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(“device”, “iPhone Retina (4-inch 64-bit)”);
    capabilities.setCapability(“app”, “/Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app”);
    wd = new RemoteWebDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
    wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @BeforeMethod
    public void m1(){
    System.out.println(“inside m1”);
    }

    @Test(priority=1)
    public void testFirst() throws InterruptedException {
    System.out.println(“inside testFirst”);
    wd.findElement(By.xpath(“//window[3]/alert[1]/tableview[1]/cell[1]”)).click();
    wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[2]”)).click();
    wd.findElement(By.name(“Back”)).click();
    System.out.println(“Finish testFirst”);
    Thread.sleep(10000);
    }

    @AfterMethod
    public void finish(){
    System.out.println(“Finish After Method”);
    }

    @AfterTest
    public void tearDown() throws Exception {
    System.out.println(“inside tear down”);
    //wd.close();
    wd.quit();
    }

    }
    //Test2.java
    public class Test2 implements UIConstants {
    public WebDriver wd = null;

    @BeforeTest
    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(“device”, “iPhone Retina (4-inch 64-bit)”);
    capabilities.setCapability(“app”, “/Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app”);
    wd = new RemoteWebDriver(new URL(“http://0.0.0.0:4723/wd/hub”), capabilities);
    wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @BeforeMethod
    public void m1(){
    System.out.println(“inside m1”);
    }

    @Test(priority=1)
    public void testSecond() throws InterruptedException {
    System.out.println(“inside testSecond”); wd.findElement(By.xpath(“//window[1]/scrollview[1]/button[5]”)).click();
    wd.findElement(By.xpath(“//window[1]/button[2]”)).click();
    System.out.println(“Finish testSecond”);
    Thread.sleep(10000);
    }
    @AfterMethod
    public void finish(){
    System.out.println(“Finish After Method”);
    }

    @AfterTest
    public void tearDown() throws Exception {
    System.out.println(“inside tear down”);
    //wd.close();
    wd.quit();
    }
    }

    //Testing.xml

    //Appium Error on console –

    info: Error: Requested a new session but one was in progress
    at Appium.start (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/appium.js:91:15)
    at exports.createSession (/Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:147:16)
    at callbacks (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:164:37)
    at param (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:138:11)
    at pass (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:145:5)
    at nextRoute (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:100:7)
    at callbacks (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:167:11)
    at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/server/controller.js:37:7
    at callbacks (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:164:37)
    at param (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/express/lib/router/index.js:138:11)

    debug: Request received with params: {“desiredCapabilities”:{“platform”:”Mac”,”app”:”/Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app”,”browserName”:”iOS”,”device”:”iPhone Retina (4-inch 64-bit)”,”version”:”6.1″}}
    error: Failed to start an Appium session, err was: Error: Requested a new session but one was in progress

    info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Requested a new session but one was in progress)”,”origValue”:”Requested a new session but one was in progress”},”sessionId”:”108bc9a5-3709-404d-99b3-81f9138fe42c”}
    POST /wd/hub/session 500 4ms – 278b

      • I have turned on Override Existing Session but its not able to launch the server. Its trying for 3 attempt then giving error -“Failed to start an Appium session, err was: Error: Instruments crashed on startup”

        info: Attempting to retry launching instruments, this is retry #2
        info: Attempting to run app on iPhone Retina (4-inch) – Simulator – iOS 6.1
        info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w iPhone Retina (4-inch) – Simulator – iOS 6.1 /Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments
        info: And extra without-delay env: {“DYLD_INSERT_LIBRARIES”:”/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd/InstrumentsShim.dylib”,”LIB_PATH”:”/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd”}
        info: And launch timeout: 90000ms

        info: [INST STDERR] Instruments Usage Error : Unknown hardware device specified: iPhone Retina (4-inch) – Simulator – iOS 6.1

        info: [INST] Known Devices:

        info: [INST] Jitendra Kumar’s MacBook Pro (com.apple.instruments.devices.local)
        iPhone – Simulator – iOS 7.1
        iPhone Retina (3.5-inch) – Simulator – iOS 7.1
        iPhone Retina (4-inch) – Simulator – iOS 7.1
        iPhone Retina (4-inch 64-bit) – Simulator – iOS 7.1
        iPad – Simulator – iOS 7.1
        iPad Retina – Simulator – iOS 7.1
        iPad Retina (64-bit) – Simulator – iOS 7.1

        info: [INSTSERVER] Instruments exited with code 255

        info: Attempting to retry launching instruments, this is retry #3
        info: Attempting to run app on iPhone Retina (4-inch) – Simulator – iOS 6.1
        info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w iPhone Retina (4-inch) – Simulator – iOS 6.1 /Users/jitendrakumar/Desktop/Helath4MeApp_Prd/ConsumerTransparency.app -e UIASCRIPT /Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments
        info: And extra without-delay env: {“DYLD_INSERT_LIBRARIES”:”/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd/InstrumentsShim.dylib”,”LIB_PATH”:”/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/thirdparty/iwd”}
        info: And launch timeout: 90000ms

        info: [INST STDERR] Instruments Usage Error : Unknown hardware device specified: iPhone Retina (4-inch) – Simulator – iOS 6.1

        info: [INST] Known Devices:

        info: [INST] Jitendra Kumar’s MacBook Pro (com.apple.instruments.devices.local)
        iPhone – Simulator – iOS 7.1
        iPhone Retina (3.5-inch) – Simulator – iOS 7.1
        iPhone Retina (4-inch) – Simulator – iOS 7.1
        iPhone Retina (4-inch 64-bit) – Simulator – iOS 7.1
        iPad – Simulator – iOS 7.1
        iPad Retina – Simulator – iOS 7.1
        iPad Retina (64-bit) – Simulator – iOS 7.1

        error: Instruments crashed on startup

        info: [INSTSERVER] Instruments exited with code 255

        info: Killall instruments
        info: Stopping iOS log capture

        debug: Sending command to instruments: au.bundleId()

        info: Killing the simulator process
        info: Instruments launched. Starting poll loop for new commands.
        info: Pushing command to appium work queue: “au.bundleId()”
        info: Killing any other simulator daemons

        info: Cleaning app state.

        error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

        info: No folders found to remove
        info: Cleaning up appium session
        info: Error: Instruments crashed on startup
        at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:351:31)
        at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:294:12)
        at ChildProcess.EventEmitter.emit (events.js:98:17)
        at Process.ChildProcess._handle.onexit (child_process.js:797:12)
        info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments crashed on startup)”,”origValue”:”Instruments crashed on startup”},”sessionId”:null}
        POST /wd/hub/session 500 43743ms – 210b

  • Hi

    I am trying to capture the error screenshot for my test cases for IOS. But its throwing error like “java.lang.ClassCastException”. Please tell me the code or package needs to install for screenshot capture.

  • Hi Smriti ,
    I am trying to run my app built on iPhone5+iOS7.1 using xcode 5.1.1+iOS SDK 7.1 ,
    But the appium(0.18.0) throws following error and unable to launch app on real device .
    Could you please take a look into this ,thanks in advance .

    info: Instruments is at: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments
    info: [INSTSERVER] Instruments socket server started at /tmp/instruments_sock
    info: Attempting to run app on real device with UDID 4358fddc6e4e8aa220594b3e06650c9af57e3eda
    info: Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -w 4358fddc6e4e8aa220594b3e06650c9af57e3eda com.example.awe-REL -e UIASCRIPT /Applications/Appium 4.app/Contents/Resources/node_modules/appium/node_modules/appium-uiauto/uiauto/bootstrap.js -e UIARESULTSPATH /tmp/appium-instruments
    info: And extra without-delay env: {}
    info: And launch timeouts (in ms): {“global”:90000}
    info: [INST STDERR] 2014-04-21 21:34:29.536 instruments[50166:707] unable to locate CFBundleIdentifier for path: com.example.awe-REL
    info: [INST STDERR] Instruments Trace Error : Error Starting Recording
    info: [INSTSERVER] Instruments exited with code 253
    info: Killall instruments
    info: Attempting to retry launching instruments, this is retry #1
    info: Cleaning app state.

    info: No folders found to remove

    error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

    info: Cleaning up appium session
    info:Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/Applications/Appium 4.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:385:31)
    at null. (/Applications/Appium 4.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:328:12)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:797:12)
    info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments crashed on startup)”,”origValue”:”Instruments crashed on startup”},”sessionId”:null}
    POST /wd/hub/session 500 36342ms – 210b

  • @Smriti ,
    Here are the details ,
    Capability :-
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“device”, “iPhone5”);
    capabilities.setCapability(“udid”, “4358fddc6e4e8aa220594b3e06650c9af57e3eda”);
    capabilities.setCapability(“bundleid”, “com.example.awe-REL”);
    driver = new SwipeableWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    Appium Preferences :-
    General:-Reset app state after each session ,kill process using appium server port before launch and dev settings enabled
    IOS:-Dev settings enabled

    Somehow the instrument is getting crashed on startup,
    info: [INST STDERR] 2014-04-21 21:34:29.536 instruments[50166:707] unable to locate CFBundleIdentifier for path: com.example.awe-REL
    info: [INST STDERR] Instruments Trace Error : Error Starting Recording
    info: [INSTSERVER] Instruments exited with code 253
    info: Killall instruments

    The app launch on simulator works fine ,only on the real device it has a problem .
    Setup Info:- iPhone5+iOS7.1+appium(0.18.0)+OS X 10.8.5

  • @Smriti
    Thank you very much for writing up such a detailed installation guide.
    I have followed your instructions but I am getting the following error message:

    A new session could not be created. (Original error: You specified a UDID and ipa but did not include the bundle id) (WARNING: The server did not provide any stacktrace information)

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“device”, “iPad”);
    capabilities.setCapability(“udid”, “15e028ea39ff5b945d078dasfdaf334343”);
    capabilities.setCapability(“bundleid”, “com.test.test”);
    capabilities.setCapability(“app”, “/Users/Home/Desktop/Test.ipa”);
    driver = new RemoteWebDriver( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    I did provide my bundle id in desired capabilities. What am I missing?
    I addition do you mind adding section on how to start appium server from command line?

    Greatly appreciate your help in advance.

    Thanks,
    Alex

      • This path is wrong –
        capabilities.setCapability(“app”, “/Users/Home/Desktop/Test.ipa”);

        You just need to mention your app name here which you are testing as you are running scripts on device I believe.

        So , when running on real device , just mention like –
        capabilities.setCapability(“app”, “AppName.ipa”); where ‘AppName’ is the name of your app.

        • Hi Smriti,
          I guess I am missing something but when leave out application path and just indicate your app.ipa I get the following error:

          FAILED CONFIGURATION: @BeforeMethod setUp
          org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: dyld: Library not loaded: @executable_path/../lib/libimobiledevice.3.dylib
          Referenced from: /Applications/Appium.app/Contents/Resources/node_modules/appium/build/libimobiledevice-macosx/ideviceinstaller
          Reason: image not found

          Any help would be greatly appreciated.

          Thanks

  • Hi Smriti,
    No I am not able to launch application on the simulator either but I am getting a different error when I make an attempt to run on a simulator.

    Here is the error:
    org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Instruments crashed on startup) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 24.09 seconds

    Here are my capabilities:

    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);

    capabilities.setCapability(CapabilityType.VERSION, “7.1″);

    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);

    capabilities.setCapability(“device”, “iPhone”);

    capabilities.setCapability(“app”,”/Users/Home/Desktop/test.ipa”);

    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    I read on appium forum that such error may happen when appium is installed with sudo but I am not sure how to fix that.
    Any help would be greatly appreciated.

    Thanks!

  • Hi

    I am able to launch the run the application in device but when i am trying to run in simulators its getting crashed for four to five times then its working rarely. Please help us what and all needs to done to work properly in simulators. Also it is very slow in simulators. Please help us in detail….
    (Proper capabilities setup i have done, why this issue is happening is it because of machine configurations or xcode and simulator version pblm or from appium server side problem or my application problem)

  • Hi, I followed all the steps and created the eclipse project and importing all the jars mentioned above in project i created.I created the test class too but im not able to run the project. I’m running the project as a java application but then it ask for select java application with a list of many items. I tried to select the selenium server but nothing happens in appium or in simulator.
    Any idea what i did wrong?

    • Looks like the project isn’t properly created.
      I have updated my project with the steps how to create a project. Please refer that and let me know then if you are able to run or not.

  • Hi

    This is the error i am getting.
    “error: Instruments socket client never checked in; timing out

    info: Cleaning up appium session
    info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments did not launch successfully–please check your app paths or bundle IDs and try again)”,”origValue”:”Instruments did not launch successfully–please check your app paths or bundle IDs and try again”},”sessionId”:null}”

    I have given my bundle id and app path correctly only.
    Its running correctly in device, but creating problem in simulators

    Please suggest what exactly need to do in capabilities code, or is this issue related to application or related to system configurations due to speed issue.

  • Hi Smriti

    I have used the same capabilites as you mentioned in the blog, but the path i am taking the app was from xcode as i develop the app from xcode.

    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);

    capabilities.setCapability(CapabilityType.VERSION, “6.1”);

    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);

    capabilities.setCapability(“device”, “iPhone”);

    capabilities.setCapability(“app”,”/Users/xcode/library/deriveddata/App.app”);

    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities); ”

    Regarding appium server in the appium dialog box i am setting the app path and uncheck the prelaunch application options from preferences.

    So the simulator error which i mentioned inthe above post is due to anyother technical challenges. I am using appium 0.12.and using xcode 5.1 with ios 7.1 simulators. Please help me out to solve the issue.

  • Hi

    Without xcode how to built my application. How to install application in simulators and devices. And what kind of capabilities need to give on my scripts.

    So what kind of file i should have so that i can install it in simulators and devices directly and make my scripts running

    • Hey Deepthi

      I have mentioned all capabilities to set to run on simulator and device in my post itself.

      To run on simulator -> you need “.app” of your app.
      If your app is in store , you can get bundle id of the app :

      – Download app from itunes store -> open in finder.
      – There will be a one plist file -> you can find bundle id there.

      Please go through the post once and let me know in case of any queries.

  • Hi

    “Can you update your appium app and try once. The version which you are using right now is pretty old.”

    For the above one, pls let me know whatverison exactly i can use to avoid the below simulator issue.
    “error: Instruments socket client never checked in; timing out

    info: Cleaning up appium session
    info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments did not launch successfully–please check your app paths or bundle IDs and try again)”,”origValue”:”Instruments did not launch successfully–please check your app paths or bundle IDs and try again”},”sessionId”:null}”

  • Hey,

    Thank you for such a wonderful tutorial. But I’m having problem in running this test.
    I hope you can help me. When i run Java application then a “bsh console” start thats it. Will you please help me finding my issue.

  • Hi

    Even i used appium 1.0 version and still my application crashes in simulator. So is there any workaround for this. Is there any other settings or command thats need to run in appium.???

    I have installed appium.app and then i have open the appium application.Then i gave the .app path and server capabilites in appium dialog box. Is there anyother thing needs to be done. For prelaunching the application itself its crashed automatically.
    please help me on this…Is anyother thing i need to do or any problem in the application…

    • Any error you are getting in the logs? Make sure you override all previous sessions option as well in appium.
      Also there are some changes in the new Appium version regarding capabilities and platform and make sure you change them accordingly.
      Only entering “.app” field in appium server should be good to go for simulator launch.
      Refer the migration docs and the 1.0 desired capabilities

      Check with all this and update. Then also if it doesn’t work -> send me the updated capabilities being set in your code along with all your appium settings being set like “prelaunch application” and the fields which you are setting up in appium server say “.app” , “force device” etc along with their values.

  • Hey
    Nice work .. I have few queries related to Mobile Web.
    When I tried to test Safari Browser in iPhone5, I am getting below error.
    Though I gave write access to “Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Applications/MobileSafari.app”, still I am getting the same error.

    ‘================================================================

    Running iOS Checks

    ✔ Xcode is installed at /Applications/Xcode.app/Contents/Developer

    ✔ Xcode Command Line Tools are installed.

    ✔ DevToolsSecurity is enabled.

    ✔ The Authorization DB is set up properly.

    ✔ Node binary found at /usr/local/bin/node
    ✔ iOS Checks were successful.

    Running Android Checks
    ✖ ANDROID_HOME is not set
    Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.

    info: Starting Appium in pre-launch mode

    info: Pre-launching app
    info: Configuring Safari session
    info: Trying to use mobile safari, version null

    info: Looking for built in app MobileSafari

    info: Got app, trying to move /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Applications/MobileSafari.app to tmp dir

    info: Copied MobileSafari to /tmp/Appium-MobileSafari.app

    info: Got configuration error, not starting session

    error: Could not prepare mobile safari with version ‘7.1’: Error: We don’t have write access to /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/Applications/MobileSafari.app, please re-run authorize as homedepot

    info: Cleaning up appium session
    ‘===================================================================

    • Hey
      It says in logs that ‘ANDROID_HOME’ is not set. You need to set your path variables in Mac.
      For that , follow this –

      [1] Open terminal and type –
      vi ~/.bash_profile

      [2] Say I want to add my platform-tools sdk path . For that , write this to the file –
      export PATH=$PATH:/Users/abc/Desktop/smriti/Android_Development/AndroidWorkspace/android-sdk-macosx/platform-tools

      [3] To add sdk-tools path as well , modify the same file as –

      export PATH=$PATH:/Users/abc/Desktop/smriti/Android_Development/AndroidWorkspace/android-sdk-macosx/platform-tools:/Users/abc/Desktop/smriti/Android_Development/AndroidWorkspace/android-sdk-macosx/tools

      [4] To make changes and save –
      . $HOME/.bash_profile

      [5] Check path now –
      echo $PATH

      Path will be set.

  • Hi Smriti,

    I have added two libs to project (Selenium-server-standalone-2.41.0.jar, selenium-java-2.41.0.zip) and when i run application i m getting below exception.

    server :127.0.0.1 Port:4723 in both java code and appium tool.

    do i need ios-server-standalone-0.6.6-SNAPSHOT.jar to add?

    Exception in thread “main” org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
    Build info: version: ‘2.41.0’, revision: ‘3192d8a’, time: ‘2014-03-27 17:17:32’
    System info: host: ‘Iphone.local’, ip: ‘192.168.1.84’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9’, java.version: ‘1.7.0_55’
    Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:589)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:126)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:153)
    at com.rtem.firsttest.FirstTestCases.setUp(FirstTestCases.java:58)
    at com.rtem.firsttest.FirstTestCases.main(FirstTestCases.java:29)
    Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:579)
    at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:178)
    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
    at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
    at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at org.openqa.selenium.remote.HttpCommandExecutor.fallBackExecute(HttpCommandExecutor.java:322)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:301)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:568)
    … 5 more

  • Hi

    Whether appium supports Object ID to identify the elements present in the mobile application for IOS. If yes share me the sample code how to identify that 🙂

  • Can you please provide sample .app file for testing or can you please help how to get one.

    Currently I am using InternationalMountanins.app from the below website .
    http://seleniumworks.blogspot.in/2013/12/appium-native-ios-app-testing-webdriver.html
    But I am getting error message “org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Instruments crashed on startup) (WARNING: The server did not provide any stacktrace information) “

    • Hey Priya

      Whatever app you want to perform automation on , take the “.app” file if you want to run on simulator or use directly “.ipa” file if you want to run on real device.

      Let me know all the capabilties being set in your code as well as the fields being used in Appium server so that I can have a look.

  • Do you have any idea how to handle menu inside which i have delete option using appium? In android device we get a menu bar which i am not able to detect using appium inspector/uiautomatorviewer. thanks in advance.

  • Hi smriti
    I am new to appium and following your blog to test my apply appium on my application. It helped me alot till now but i got stuck at some point. When i run my test in eclipse after navigating two or three windows the simulator gets terminated, i.e the sign in and sign up process goes right but when it comes to welcome screen the simulator gets terminated after 3 secs.
    Well there are 4 buttons on my welcome screen and for some button the appium generates two lines in scripts after tap and same thing happen again when i run that script in eclipse.
    I have looking forward for your help.
    Please reply ASAP

    Thanks Ankita

    • You should refer to the logs in the Appium as to what the error is – maybe the script is unable to find an element which you are trying to tap on resulting in termination. Add some delay between each tap event as it takes time to switch screens and find elements to tap.

      Add print statements as well in your test cases to find out exactly after what point the script terminates.

  • Hi Smriti,
    I am getting below mentioned error while using below given code.
    After execution simulator open once and close immediately and appium throws below given error.
    Please help.
    [INST STDERR] Instruments Usage Error : Could not remove existing output document ‘file://localhost/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/instrumentscli0.trace’: Error Domain=NSCocoaErrorDomain Code=642 “You can’t save the file “instrumentscli0.trace” because the volume “Appium” is read only.” UserInfo=0x7fa2f5623210 {NSFilePath=/Volumes/Appium/Appium.app/Contents/Resources/node_modules/appium/instrumentscli0.trace, NSUnderlyingError=0x7fa2f561ee20 “The operation couldn’t be completed. Read-only file system”}.

    File appDir = new File(“/Users/qc/Desktop/ios/”);
    File appDir = new File(System.getProperty(“user.dir”)+”\\Users\\qc\\Desktop\\ios\\”);
    File app = new File(appDir, “abc.app”);
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);
    capabilities.setCapability(CapabilityType.VERSION, “6.0”);
    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);
    capabilities.setCapability(“app”, app.getAbsolutePath());
    System.err.println(“5”);
    driver = new RemoteWebDriver(new URL(“http://localhost:4723/wd/hub”),capabilities);
    System.err.println(“8”);
    Thread.sleep(40000);
    System.out.println(“App launched”);

    • You shouldn’t run Appium.app from a disk image.
      Copy it from the disk image (the dmg file downloaded and opened) onto your hard drive and run from there.

      Applications that are distributed on disk images (.dmg files) are designed to be installed using drag and drop. You can safely drag and drop the application from the virtual drive into your Applications folder and use it from your Applications folder.

  • Hi Smiriti,
    I am using Appium 1.1.0, and java-client 1.2.1 and trying to automate an iOS app targeting iOS simulator 7.0. I resolved all issues, but got stuck on one issue that I am not able to find one element which is there in page source. This element is enabled, but not visible. We need to scroll up to make the button visible, but scroll is also not working on this page.

    Following are the approaches I have tried to find that element.

    driver.findElement(By.name("Check Out")).click();
    //driver.findElement(By.xpath("xpathElmFromAppiumInsepector"));
    //driver.findElement(By.name("Check Out")).click();
    //driver.findElement(MobileBy.AccessibilityId("Check Out"));
    //driver.findElement(MobileBy.IosUIAutomation("Check Out"));
    //driver.findElement(MobileBy.IosUIAutomation("Check Out"));
    //driver.findElementByIosUIAutomation("Check Out"));

    following is the page source portion having this element

    One more thing that I tried switching from native view to webview. But even then it did not worked.
    Please help if you faced such issue.
    Thanks Vikas.

    • Scroll on a page can be done through this –

      RemoteWebDriver wd = null;

      wd.executeScript("mobile: swipe", new HashMap() {
      {
      put("touchCount", (double) 1);
      put("startX", startX);
      put("startY", startY);
      put("endX", endX);
      put("endY", endY);
      put("duration", duration);
      }
      });

      Use the inspector to take the coordinates.

  • Hi smriti , plz tel me how to find xpath from appium inspector….while inspecting I am not able to see xpath for elements in appium inspector…which version of appium show xpath.

    Thanks,
    Romita

    • Whenever you launch your app in Appium – you can select any element and then under the details – it gives you all the properties associated with that element – the name , label , xpath etc irrespective of whatever appium version you are using.

      Refer this screenshot for example – http://smritituteja.in/data/inspector.png.
      Here ‘Login’ button is selected and the properties for that element can be viewed under ‘Details’ in bottom right corner.

  • Hi Smriti ,

    I am new to ios mobile automation using Appium. I was trying to test a simple calculator ios app using appium on a ios simulator. I followed your steps.

    I am using Xcode 5.1.1 , appium 1.1.o and MAC 10.8.4 ios simlator 7.1
    I have couple of problems:
    1. I am unable to see my app in the simulator when I launch appium.
    2. Inspect button doesn’t show up anything.
    3. when I run my Java application it runs without any error. But again this doesn’t launch the app.

    Is there anything I am missing?

    Please need your help.

    Thanks in advance

  • Hi smirti,
    From the article you mentioned an example for iOS simulator and real devices but when trying to run on real devices it throws an error as “Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ capability”

    I have an doubt: For simulator example script you have mentioned file path of the .app. Is same we need to pass the path of .ipa file while test in real devices?

    Can you please help me out?

    • No path is required for the “.ipa” file. It should work fine the way you mentioned it.
      Are you using the latest appium version?
      If yes , then you need to specify both device name

      capabilities.setCapability("deviceName", "iPhone Simulator");

      and platform name

      capabilities.setCapability("platformVersion", "iOS");

      See the migration docs and the 1.0 desired capabilities

      • I need to run on a real devices, the below caps for deviceName you mentioned as iphone Simulator is this correct?
        capabilities.setCapability(“deviceName”, “iPhone Simulator”);
        Below are my caps,
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(“udid”, “bf491a116fad5a36bd2283fcb966d450d8951fa1”);
        capabilities.setCapability(“bundleid”, “com.dexterity.shoply”);
        capabilities.setCapability(“app”, “Shoply.ipa”);
        capabilities.setCapability(“platformVersion”, “iOS”);
        capabilities.setCapability(“deviceName”, “iPhone”);
        wd = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
        I am still could not launch in real devices using the .ipa file.
        While trying out in appium GUI, I have passed the BundleID and UDID of the connected device, then I launch the appium, it throws an below error,
        error: Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ capability
        info: Starting Appium in pre-launch mode
        While trying appium in terminal, I have run my script using those caps it throws an error as,
        info: Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ capability)”,”origValue”:”Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ capability”},”sessionId”:null}
        But I can run in simulator by using .app
        Please help me out for run via real devices using the .ipa file!!!

  • Hi Smriti,
    I need your help again 🙁
    I am trying to launch appium server from command prompt in mac machine.I am able to launch the server from the appium.app UI by clicking on the launch button.I tried using the below commands but when I am executing the appium & it is failing.
    > npm install -g appium # get appium
    > npm install wd # get appium client
    > appium & # start appium
    I am getting the below error message in the command prompt.
    [1] 3519
    -bash: appium:command not found
    But whenI am able to do the same in Windows using appium & command .

    Can you please tell me how to launch the appium server from command prompt in MAC machine.

    Thanks

  • Hi Smriti,

    Does the .app file need to be in debug mode for the appium inspector to be able to start and access it?

  • Hi Smriti,
    Thank you for your guild lines about appium for native iOS application automation.
    But I want to know can we write objective c code for writing test cases for iOS native application automation?

  • HI smriti, I had written my tests under @test methods.. But after every @test method execution, app is closed in the simulator.. Actually am writing separate set of tests in multiple @test ‘s which are executed to be sequential.. as the session is closing am logged out of the app. so my second @test is failing. How to handle this situation?
    @test1 -> login into app and navigate to other screen
    @test2 -> perform some set of actions in that screen

    When I run, the @test1 ran successfully and app is closed. (am logged out of the app as session is closed.) so my @test2 is failing. Can you please tell me how to handle this situation???

    • Can you post here your code?
      What have you mentioned in @BeforeMethod , @BeforeTest ?

      For example :

      @BeforeTest
      System.out.println(“Setting up Appium”);

      @BeforeMethod
      System.out.println(“Starting test case”);

      @Test
      a();

      @Test
      b();

      @AfterMethod
      System.out.println(“Test case done”);

      @AfterTest
      System.out.println(“Everything executed”);

      So first @BeforeTest will be called.
      Then it will execute parallel as –
      @BeforeMethod
      a();
      @AfterMethod

      and
      @BeforeMethod
      b();
      @AfterMethod

      And at last @AfterTest will be called.

      What TestNG does is – It will find all the methods marked as @Test. After this, it will create two parallel threads, and will start executing each method in its own thread. Before and after each @Test, @BeforeMethod and @AfterMethod are executed in each thread.

      • Thanks Smriti.. Your detailed explanation about BeforeMethod, AfterMethod, BeforeTest and AfterTest helped me to solve my problem.

  • Hi Smrti,

    I have good knowledge in Objective C. I want to automate one iOS app(Like native email app). Please let me know is it possible to write test cases in Objective C and run through APPIUM. If it is possible please send me a iOS demo app with Objective C test cases written.
    Thanks in advance.

  • I am using the appium Version 1.2.0 (Cygnus). I think it is latest! Facing same issue! I could not run in real devices using those given caps.
    Sorry if any new version in appium can share the link.
    Pls help me!

      • Hi Smiriti,

        Thanks for your reply. Given below is the capabilities set-up in my code.
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability(“device”, “iPad”);
        capabilities.setCapability(“platformName”, “iOS”);
        capabilities.setCapability(“deviceName”, “Mathew’s iPad”);
        capabilities.setCapability(“udid”, “56052311bcd1b8f045e6c433da1c4b5042fa2848”);
        capabilities.setCapability(“bundleid”, “com.scottsafety.samdev”);
        capabilities.setCapability(“ipa”, “Sam.ipa”);
        driver = new RemoteWebDriver( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

        Regards,
        Mathew

  • Hi Smriti,
    Can you please let me know How can I run test script through terminal. I am facing following issue when i try to run test script:

    Error : Appium will not work if used or installed with sudo. Please rerun/install as a non-root user

  • Hi Smriti,
    Have you tried to automate the web application from appium. I am trying to automate tees cases on chrome browser but getting issue. Can you help me if you have any tutorial for same.

    Thanks in advance.

  • Hi Smriti,

    Please give me web view code
    i not able to do it

    i have tried everything context method ,switchto etc
    hash map

    But not getting output
    please help…

  • Script i am trying to run is

    package shivaniios;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;

    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.List;
    import java.util.concurrent.TimeUnit;

    public class MyFirstClass
    {
    public static void main(String[] args) throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“appium-version”, “1.2”);
    capabilities.setCapability(“platformName”, “iOS”);
    capabilities.setCapability(“platformVersion”, “7.1”);
    capabilities.setCapability(“deviceName”, “iPhone”);
    capabilities.setCapability(“app”, “/Users/admin/Downloads/Wynk.app”);
    WebDriver wd = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
    wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

    //Click on continue button
    WebElement button_Continue = wd.findElement(By.name(“Continue”));
    button_Continue.click();

    //Click on skip button
    WebElement button_Skip = wd.findElement(By.name(“Skip”));
    button_Skip.click();

    //Click on Skip Tour button
    WebElement button_Skiptour = wd.findElement(By.name(“Skip Tour”));
    button_Skiptour.click();

    //Click on Close Tip button
    WebElement button_Closetip = wd.findElement(By.name(“Close Tip”));
    button_Closetip.click();

    //Click on Player button
    //WebElement button_Player = wd.findElement(By.name(“Player”));
    //button_Player.click();

    //wd.findElement(By.name(“Player”)).click();

    //Click on seeAll link for moods
    wd.findElement(By.xpath(“//UIATableCell[@name=’Moods’]/UIAButton”)).click();

    //syntax of xpath
    //tagName[@attribute=’attributevalue’]/

    // Number of moods element
    List e = wd.findElements(By.tagName(“UIACollectionCell”));
    //div, tr ,td,
    int actualCount = e.size();
    int expectedCount = 14; // hardcoded

    if(expectedCount==actualCount)
    {
    System.out.println(“passed”);
    }
    else
    {
    System.out.println(“Failed”);
    }
    wd.close();
    }
    }

    Following exception is coming while executing
    Exception in thread “main” org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. (WARNING: The server did not provide any stacktrace information)

    Command duration or timeout: 2.63 seconds

    Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:30’

    System info: host: ‘admins-MacBook-Pro-87.local’, ip: ‘192.168.1.197’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.9.4’, java.version: ‘1.7.0_55’

    Session ID: 31031deb-5b8e-4d4d-96eb-6995fb7b7927

    Driver info: org.openqa.selenium.remote.RemoteWebDriver

    Capabilities [{platformVersion=7.1, app=/Users/admin/Downloads/Wynk.app, platform=MAC, databaseEnabled=false, javascriptEnabled=true, deviceName=iPhone, platformName=iOS, browserName=iOS, appium-version=1.2, webStorageEnabled=false, desired={platformVersion=7.1, app=/Users/admin/Downloads/Wynk.app, platformName=iOS, deviceName=iPhone, appium-version=1.2}, locationContextEnabled=false, warnings={}, takesScreenshot=true}]

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)

    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)

    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)

    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)

    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)

    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)

    at shivaniios.MyFirstClass.main(MyFirstClass.java:49)

  • Hi Smriti,
    Thanks for the detailed blog, it was very helpful.
    I need help, please let me know/confirm the below:
    – I have an .ipa file and it is already installed on the real device. I don’t have the code to build the app. I am trying to use Appium Inspector but it throws an error- “could not get session list”. I am not sure what to enter for the ‘App Path’ in the appium UI.
    I used UDID, Bundle Id, prelaunch and the app launches but inspector doesn’t work.
    – Also, when using Appium UI, should I explicitly start Appium server from command line as well?
    Appreciate your help with this

    • Hi Smriti,

      I went through this blog and looks good.

      Currently I have .ipa file and same app can be installed through test flight. I don’t have the app source code. I tried extracting the files from .ipa file using Archive Utility but there was no plist file. I am not sure how do I get the bundle id for this app- (either from .ipa file or by using the installed app and what is the process?) as i want to automate this app test on real device

      Thanks,
      Neha R M

  • Hi Smriti, It is nice document for a beginner, do you have any idea on executing scripts on multiple iOS/android devices? please let me know if you have any related doc.

    Thanks
    Gopal

    • One Appium instance handles only one test session at a time. If you want to test your Android application on multiple devices, you can connect multiple Android devices to your machine, start multiple Appium instances on different ports with different UDIDs, and instigate multiple testscripts pointing to different ports.
      However, you cannot do the same for iOS. This is because Appium uses native Instrumentation to communicate with the device, and Instrumentation allows only one device at a time.

      Can refer here

  • Hi Smriti,
    Really appreciate your effort to help the community with your knowledge in Appium.
    I am new to Appium and trying learn and install it on a windows machine. I am having an issue starting the inspector. When I clicked on “Refresh”button on the Inspector Window, I see the error “Message: Error Starting Selenium Driver”.
    Could you please suggest how to resolve this issue.

    I am already using Selenium (Selenium Webdriver, Java, Eclipse, MVN, TestNG all are installed) for functional testing. And trying to install Appium on the same machine. Installed Android Emulator Virtual Device, Emulator has internet connection. Please let me know how I can make a connection between Appium Inspector and the Selenium Driver.

    Thanks in Advance.

  • Hi Smriti,

    Thanks for posting. It is really helpful.

    I just noticed, you didn’t mention how to integrate the java class to Appium. Also, the UDID keeps changing from iOS7 onwards. I hope the identifier in Organizer is UDID. Correct?

    I am getting the following error once I launched the server and inspector.

    info: Launching instruments

    info: [debug] Attempting to run app on real device with UDID 0058679bc8d12f8a56243d8de88b0d7e14dc09c0
    info: [debug] Spawning instruments with command: /Applications/Xcode.app/Contents/Developer/usr/bin/instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate -D /tmp/appium-instruments/instrumentscli0.trace -w 0058679bc8d12f8a56243d8de88b0d7e14dc09c0 com.ampchroma.simplexgrinnell.uat.mobilecontainer -e UIASCRIPT /Users/rsangili/Library/Application Support/appium/bootstrap/bootstrap-3fd3829137e4c5d0.js -e UIARESULTSPATH /tmp/appium-instruments

    info: [debug] And extra without-delay env: {}
    info: [debug] And launch timeouts (in ms): {“global”:90000}

    info: [debug] [INST STDERR] 2014-09-08 13:32:05.047 instruments[3495:507] Permission to debug com.ampchroma.simplexgrinnell.uat.mobilecontainer was denied. The app must be signed with a development identity (e.g. iOS Developer).

    info: [debug] [INST STDERR] Instruments Trace Error : Error Starting Recording

    Thanks,
    Ramesh

  • Hi Smriti ,

    I am doing ioS Mobile automation testing for Native application.

    I am getting an system generated location alert “… would like to use your Current Location”while opening the application in simulator . I am not able to handle this with Selenium as i am not able to capture this alert box using Inspector .

    Is there any way to handle this with the help of capabilities (while setting the capabilities ) .I am using the below code :
    capabilities.setCapability(CapabilityType.VERSION, “7.0”);
    capabilities.setCapability(CapabilityType.PLATFORM, “Mac”);
    capabilities.setCapability(“Device”, “iPhone Simulator”);
    capabilities.setCapability(“app”,”/Users/test/EclipseMediaSourceTree/EclipseMedia/build/Release-iphonesimulator/EclipseMedia.app”);*/
    //capabilities.setCapability(“app”,”sauce:storage:EclipseMedia.app.zip”);

    try{
    driver = new RemoteWebDriver(
    new URL(remoteDriverURL), capabilities);
    }

    I am using Java + Appium + Web Driver +Sikuli.

    Please help on this .

    • You can set “autoAcceptAlerts” desired capability to “true”.
      This accepts iOS privacy access permission alerts (e.g., location, contacts, photos) automatically if they pop up. Default setting is false.

  • hello..i would like to ask u how can i a link inside the url for example i open the url inside chrome as http://www.google.com

    import java.net.MalformedURLException;
    import java.net.URL;
    import java.util.concurrent.TimeUnit;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.remote.CapabilityType;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;

    import org.testng.annotations.BeforeMethod;
    import org.testng.annotations.Test;

    public class browser {

    private WebDriver driver;
    private String baseUrl;

    @BeforeMethod
    public void testApp() throws Exception{

    final DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);
    capabilities.setCapability(“deviceName”,”Android”);
    capabilities.setCapability(“platformVersion”, “4.4.2”);
    capabilities.setCapability(“platformName”, “Android”);
    capabilities.setCapability(“appium-version”, “1.2.2”);
    capabilities.setCapability(“app-activity”, “com.android.chrome.MainActivity”);
    capabilities.setCapability(“Device ID”, “KOT49H.I9500XXUGNI1”);
    capabilities.setCapability(“takesScreenshot”, true);
    capabilities.setCapability(“app”, “/data/app/com.android.chrome-1.apk”);
    capabilities.setCapability(“appPackage”, “/data/data/com.android.chrome/app_chrome/Default”);

    driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”),
    capabilities);
    driver.manage().timeouts().implicitlyWait(3000, TimeUnit.SECONDS);

    }

    @Test
    public void testUrl() throws InterruptedException{
    baseUrl = “http://www.google.com”;
    driver.get(baseUrl + “/”);

    }
    }

    now it open the google page but i want it to continue test the button inside it for example the images link..how can i do it…

    thanks

  • Hi Smriti,
    Is their is any way to install and uninstall the app (.ipa) file to iOS real device using Appium.
    Please let me know if you have any other way do it programatically.

  • HI Smriti/All,

    While automating native iOS app, we have Left Menu view which is an overlay on home screen of app
    Now here, we are not able to identify elements of left menu using appium inspector
    Using precise tap, it is working by using x and y co-ordinates
    But is there any other robust way as we should be depend on co-ordinates
    I tried using classname but its not working

    Can you help me here..

    Thanks
    Milan

    • From Appium 1.x , the following locator strategies have been removed:

      – name
      – tag name

      They have now added “accessibility_id” locator which does same thing what “name” used to do and “tag name” has been replaced by “class name”.

      Can refer here

      Let me know if it works.

  • Hi Smriti,

    Did you run Appium on iPhone.
    I set following capabilities, but it’s not working and i got following errors.do u have any idea on that.

    Error: Could not determine your device from Appium arguments or desired capabilities. Please make sure to specify the ‘deviceName’ and ‘platformName’ capabilities

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.BROWSER_NAME, “”);//iOS 8.1
    capabilities.setCapability(“browserName”, “iPhone”);
    capabilities.setCapability(“platformName”, “iOS”);
    capabilities.setCapability(“platformVersion”, “8.1”);
    capabilities.setCapability(“deviceName”, “iPhone 5s”);
    capabilities.setCapability(“device”, “iPhone 5s”);
    capabilities.setCapability(“udid”, “a96463086e3cdbaxxxxxx”);

    capabilities.setCapability(“bundleid”, “com.wf.enterprise.phone”);
    capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);
    capabilities.setCapability(CapabilityType.VERSION, “8.1”);
    capabilities.setCapability(“app_activity”, “MainActivity”);
    capabilities.setCapability(“app”, app.getAbsolutePath());

    • Please note –
      [1] capabilities.setCapability(“app_activity”, “MainActivity”); //this is used in case of Android apps automation not iOS

      [2] ‘device’ and ‘version’ capabilities are no longer used from Appium 1.x

      [3] You can get deviceName by this command – instruments -s devices . After you connect your device to your machine , device name whould display there.

      [4] These aren’t required –
      capabilities.setCapability(CapabilityType.BROWSER_NAME, “iOS”);
      capabilities.setCapability(CapabilityType.VERSION, “8.1”);

      As you have used these separately –
      capabilities.setCapability(“browserName”, “iPhone”);
      capabilities.setCapability(“platformVersion”, “8.1”);

      [5] ‘browserName’ is the name of mobile web browser to automate. It can be left blank if automating an app.

      [6] You havn’t mentioned any app path , so this will not work –
      capabilities.setCapability(“app”, app.getAbsolutePath());

      Should give some path as given in sample code in the post –
      File appDir = new File("/Users/abc/Desktop/smriti/iPhoneSimulator");
      File app = new File(appDir, "XYZ.app");

      Then use –
      capabilities.setCapability("app", app.getAbsolutePath());

  • ignore my previous post. I am not able to run app, able to install app.

    error: Failed to start an Appium session, err was: Error: Instruments crashed on startup

    info: [debug] Cleaning up appium session
    info: [debug] Error: Instruments crashed on startup
    at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:387:31)
    at null. (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:308:12)
    at ChildProcess.emit (events.js:98:17)
    at Process.ChildProcess._handle.onexit (child_process.js:810:12)
    info: [debug] Responding to client with error: {“status”:33,”value”:{“message”:”A new session could not be created. (Original error: Instruments crashed on startup)”,”origValue”:”Instruments crashed on startup”},”sessionId”:null}

    • Activity in case of Android is the launcher activity (i.e activity name for the Android activity to launch from your package. It is the app’s main activity to be called which will also launch the app). This is often a splash activity or main activity.

  • Hi Smriti,

    I’m a newbie to test automation on mobile devices and wanted to request some help with the initial set up. I’m using a mac and also, are you using the xcode emulator ?
    Also, when I try to use Start server in Appium, it just sits there, does nothing. However, if I start the NodeJS server from the command line, it does start.

    I’m probably doing it all wrong so wanted to check if you can help me with some setup. Sorry if it appears too silly but since your setup instructions are for windows, not sure if you have one for Macs,

    Pls do let me know when u get a chance,

    Thanks

    Vijay

    • Hey
      Running scripts on device will be much faster in case of iOS rather than simulator(as far as I have experienced 🙂 ).
      All steps mentioned there have been performed on a Mac only (as to run automation scripts for iOS , you need a Mac machine. It can’t be done on Windows as Xcode needs to be present for Appium to work). The only difference in my post is that I have used Appium.app directly instead of node.js.

  • Hi,

    I already tried with simulater its working fine when same thing tried in Real device its show error like(“unable to install safarilauncher.app).
    How can I automate the web application in real IOS device.
    This is my Desiredcapabilities code:
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“browserName”, “Safari”);
    capabilities.setCapability(“deviceName”, “iPhone”);
    capabilities.setCapability(“udid”,”xxxxxxxxxx”);
    capabilities.setCapability(“platformName”, “iOS”);
    capabilities.setCapability(“platformVersion”, “8.1”);
    RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”),
    capabilities);

    remoteWebDriver.get(“http://www.google.com”);

    Please guide me. I am using mac osx(10.10.1)

  • Hi,

    Thanks for the tutorial.
    I tried with above code its working in simulater but when same thing tried in Real device its show error like(“unable to install safarilauncher.app).
    How can I automate the web application in real IOS device.
    This is my Desiredcapabilities code:
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“browserName”, “Safari”);
    capabilities.setCapability(“deviceName”, “iPhone”);
    capabilities.setCapability(“udid”,”xxxxxxxxxx”);
    capabilities.setCapability(“platformName”, “iOS”);
    capabilities.setCapability(“platformVersion”, “8.1”);
    RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”),
    capabilities);

    remoteWebDriver.get(“http://www.google.com”);

    Please guide me. I am using mac osx(10.10.1)

  • Hi Smriti

    I am getting error when trying to open Appium Inspector :

    Error: Instruments crashed on startup at Instruments.onInstrumentsExit (/Applications/Appium.app/Contents/Resources/node_modules/appium/node_modules/appium-instruments/lib/instruments.js:398:31)

    I am using Xcode 5 and appium – 1.0 and MAC OS X 10.9.

    Please help .

  • Hi Smriti,

    Thanks for your article, very useful. 🙂

    I got an error as follow when trying to execute the code on real device (the ipa was not built to run on simulator):
    org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName) (WARNING: The server did not provide any stacktrace information)

    Here is the code:
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“device”, “Iphone5s”);
    capabilities.setCapability(“udid”, “03B9AF3F61EFF48FBCB19FB6809B8E31866E5BC3”);
    capabilities.setCapability(“bundleid”, “com.ctplc.dailytimerecording”);
    capabilities.setCapability(“ipa”, “MobileTimeiOS-8.DAILY.ipa”);

    driver = new RemoteWebDriver( new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

    • With Appium moving to 1.x , they have made some changes in desired capabilites , and I believe you are using the 1.0+ appium version i.e why it clearly says – “Original error: The following desired capabilities are required, but were not provided: platformName, deviceName”.

      You need to add two more desired capabilities in your code i.e platformName (iOS or Android) and deviceName (whatever is your device name) –
      – platformName as capabilities.setCapability(“platformName”, “iOS”);

      – deviceName as capabilities.setCapability(“deviceName”, “iPhone 5s”);

      Can refer for migration docs and server capabilities for more details.

  • Hi Smriti,

    I was unable to launch my Hybrid app from iPad real device where as i am able to launch it from simulator using Appium, can you please post the detail configuration which needs to be done in order to launch the app on real device,

    below is the code which i used to launch my app on real device,

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(“deviceName”, “iPad”);
    capabilities.setCapability(“udid”, “FFFFFFFF1EA20B4DD22A4C15AE284B9AB870C91A”);
    capabilities.setCapability(“platformName”, “iOS”);
    capabilities.setCapability(“platformVersion”, “8.1.3”);
    capabilities.setCapability(“bundleid”, “com.imshealth.360.one.nexxussales”);
    capabilities.setCapability(“app”, “Engage”);
    RemoteWebDriver driver = new RemoteWebDriver( new URL(“http://0.0.0.0:4273/wd/hub”), capabilities);

    please let me know if what is wrong in the above code

  • Hey Smriti, I have one question. Is it possible to download an iOS app from app store and automate it using Appium? If so, please let me know how it can be done. And also can we use Appium on windows to test iOS apps in a real device?

  • Hey Smriti,
    I have a couple of quick questions regarding Appium with Selenium webdriver.
    1) Is it possible to download an iOS app from App Store, and automate it using iOS Simulator? If so please let me know how, it can be done?
    2) Can we test an iOS app in real device using Appium in Windows?

    • [1] App store files are ‘.ipa’. Installing .ipa files onto the Simulator is not possible. They are built for a real device architecture (ARM), which is a different architecture to x86.

      To get the ‘.app’ file from ‘.ipa’ –
      – install app from app store on real device – say app name is ‘yourApp’
      – connect device to iTunes and check ~/Music/iTunes/Mobile Applications/
      – convert the ‘yourApp.ipa’ to zip -> unzip and you will see all the files along with ‘yourApp.app’

      NOTE – To use this .app file extracted from .ipa, you need to compile your application for debug otherwise you will not be able to install it (you can ask your iOS developers on how to do it).

      [2] No for iOS Automation using Appium – Mac OS X 10.7 or higher and XCode >= 4.6.3 is a must.

  • Hi Smriti,

    Need one help- I am trying to automate iOS- App (UICatalog.app available in github) for my initial learning but I stuck up in between. I mean, I cannot enter text value in text field neither turn on switch toggle. How can i send you screenshot of app? Can we connect in skype to resolve issue quickly?
    Thanks
    Mahendra

  • Hi Smriti,

    please help me out.
    Every time i am running my app on the launch of simulator it’s showing me error
    “The application that opened iOS Simulator failed to send all of the required information (sessionUUID, sdkRoot, deviceInfo).”
    i am running using .app file.
    Previously i was able to launch using the same procedure even now i can run the previous app file of the same application but now i can’t understand what had happened.

  • Hi Smriti,

    I am new into mobile automation as of now i have done automation of mobile web based application. Now i want to automation same on iOS devices using Appium. I have done so much of google but i didn’t find any solution yet. If you have any idea about or you have such kind of document which is helpful for me to start.

    Please share it. Thanks in Advance!!

  • working with appium from terminal
    appium -a 0.0.0.0 -p 4723 -U *iphone 5c UDID*

    The error i am getting is :-
    The following capabilities are not recognized by appium , err :- ipa
    Help !!

  • Hi Smriti,
    I created automation script for hybrid application in android .same script I wanted to execute in ios .I have used webview in android.
    can I able to execute same script in ios ?.
    issue which I am facing is ,when I change to webview in scripts .I am getting an error.
    sessionId = driver.getSessionId().toString();
    Set contextNames = driver.getContextHandles();
    for (String contextName : contextNames)
    {
    System.out.println(contextNames); //prints out something like NATIVE_APP \n WEBVIEW_1
    }
    driver.context( (String) contextNames.toArray()[1]);

    but its not working in ios ,
    please help me out .
    awaiting for your reply ..

    Thanks
    Irfan

  • Hi Smriti

    Have any past experience with mobile safari automation (using appium)?

    If you have then please share the steps to start the mobile safari testing and prerequisite needed.

  • Hi Smriti,

    I am trying to automate an IOS(Flipkart.ipa) application using tool Appium .i have installed App on simulator using ios -sim command from command line , but i am not able to launch App manually or by the automation .As soon as i click on App it gets closed.Do i need to extract that .ipa to .app folder and rebuild it for target simulator????????because App is working fine in real devices

    Any help would be appreciated

    • There are two kinds of files for iOS apps: .ipa and .app
      The application package files in iOS are called .ipa files (iOS App Store Package). Each .ipa file includes a binary for the ARM architecture and can only be installed on an iOS-device. Installing .ipa files onto the Simulator is not possible.

      To run tests on real devices: your .ipa should be built with a valid Development Distribution Certificate, and device should have provisioning profile.

      To run on simulator: you need .app files. If you have .ipa file, you can unzip and extract the .app file from there.

      NOTE – To use this .app file extracted from .ipa, you need to compile your application for debug otherwise you will not be able to install it (you can ask your iOS developers on how to do it).

  • Hey,

    Thank you very much for this really good post,
    Just wanted to ask, are the scripts all updated to the latest Java client for appium iOS testing. Please let me know and thank you again.

  • Hello Smriti ,
    I am testing on a real device for an iPhone application.
    I am getting the below mentioned error on using the “.click()” method .
    “Method has not yet been implemented (WARNING: The server did not provide any stacktrace information)
    Need help for the same .

    Thanks
    Arun

Leave a Reply

Your email address will not be published. Required fields are marked *