Appium - Run First Android Automation Test Using In Eclipse

We have configured appium project in eclipse during previous post. Now we are all set to create and run first appium software automation test script on android mobile device. In this steps we will learn how to create first appium automation softwre test script in eclipse and then run it in real android mobile device.


PREREQUISITE : All previous 12 STEPS should be completed without any error.

We will use android mobile phone's default installed calculator app to run appium software automation test script. You can download Android Calculator software App from THIS PAGE if it is not installed in your mobile. This is our first appium software test so we will create simple test to sum two numbers. Follow the steps given bellow.

1. Gather Required Capabilities
Before creating appium test for android software app, You need bellow given parameters of android device and app to set webdriver capabilities in test script.
  1. Find Android Device Name : As described in THIS POST, Connect your android device with PC and get device name by running adb devices command in command prompt. My android device name Is : ZX1B32FFXF. Find your device name.
  2. Find Android Software App Package Name : You can view THIS POST to know how to get android app package name. Package name for my calculator app (Which Is Installed in my android device) is com.android.calculator2. Find your app package name.
  3. Find App Activity Name : You can view THIS POST to know how to get android app activity name. Activity name for my calculator app (Which Is Installed in my android device) is com.android.calculator2.Calculator. Find your app activity name.
  4. Find Android OS Version : In your android device, Open settings -> About phone -> Android version. My device's Android version Is : 4.4.2.
2. Launch And Start Appium Node Server
Appium should be installed and configured and also you need Server Address and Port number (which is used by appium) as described in THIS POST.

Launch Appium
  • Launch Appium from Windows Start menu.


  • For me, Server Address is : 127.0.0.1 and Port Number is : 4723.
Start Appium Node Server
Click on Start button to start appium node server as shown in bellow image. It will take some time to launch node server.

Note : You can consider appium node server is started properly once it shows log as shown in above image.

3. Create Appium Test Script In Eclipse
I have created sample appium software test script using selenium webdriver to sum two numbers using android calculator application.

Prerequisite :
  • Calculator app should be installed in your android device.
  • Install TestNG in eclipse if it is not installed. View THIS POST.
  • Also replace capabilities values of bellow given list with your own values in script. Otherwise it will not works.
  1. deviceName - Name of device which is connected with PC.
  2. CapabilityType.VERSION - OS version of your android device.
  3. appPackage - Calculator app's Package name.
  4. appActivity - Calculator app's Activity name.
Now create bellow given test class under Android package of your appium project. Usage of each code syntax is given in script itself.

SimpleAndroidCalcTest.java
package Android;

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.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SimpleAndroidCalcTest {

 WebDriver driver;

 @BeforeTest
 public void setUp() throws MalformedURLException {
  // Created object of DesiredCapabilities class.
  DesiredCapabilities capabilities = new DesiredCapabilities();

  // Set android deviceName desired capability. Set your device name.
  capabilities.setCapability("deviceName", "ZX1B32FFXF");

  // Set BROWSER_NAME desired capability. It's Android in our case here.
  capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");

  // Set android VERSION desired capability. Set your mobile device's OS version.
  capabilities.setCapability(CapabilityType.VERSION, "4.4.2");

  // Set android platformName desired capability. It's Android in our case here.
  capabilities.setCapability("platformName", "Android");

  // Set android appPackage desired capability. It is
  // com.android.calculator2 for calculator application.
  // Set your application's appPackage if you are using any other app.
  capabilities.setCapability("appPackage", "com.android.calculator2");

  // Set android appActivity desired capability. It is
  // com.android.calculator2.Calculator for calculator application.
  // Set your application's appPackage if you are using any other app.
  capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

  // Created object of RemoteWebDriver will all set capabilities.
  // Set appium server address and port number in URL string.
  // It will launch calculator app in android device.
  driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
 }

 @Test
 public void Sum() {
  // Click on DELETE/CLR button to clear result text box before running test.
  driver.findElements(By.xpath("//android.widget.Button")).get(0).click();

  // Click on number 2 button.
  driver.findElement(By.name("2")).click();

  // Click on + button.
  driver.findElement(By.name("+")).click();

  // Click on number 5 button.
  driver.findElement(By.name("5")).click();

  // Click on = button.
  driver.findElement(By.name("=")).click();

  // Get result from result text box.
  String result = driver.findElement(By.className("android.widget.EditText")).getText();
  System.out.println("Number sum result is : " + result);

 }

@AfterTest
 public void End() {
  driver.quit();
 }
}

Note : Before running above script using testng, Please make sure your android device is connected with PC with USB debugging mode enabled and Appiun node server is launched and started.

4. Running  Appium Test Script 
I hope you already know how to run software test script using testng (VIEW EXAMPLE). Run above test script and view your android phone screen. It will 
  • Open calculator app in your mobile device.
  • Tap on buttons in this sequence -> CLR, 2, +, 5 and =.
  • Get result from text area of calculator app.
  • Print result in eclipse console.
This way, We have executed very simple test script in android mobile device. If you have noticed in above example test script, We have used only name locator. We will use all different element locators (Which are described in THIS POST) in upcoming examples.

43 comments:

  1. These are awesome tutorials. Millions salute to u Aravind!

    ReplyDelete
  2. Error occurred:

    org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)

    ReplyDelete
    Replies
    1. Try with latest Appium version it will works

      Delete
  3. @Mangesh W

    Check your Spellings example :- you might have typed "devicename" instead of "deviceName"
    and also make sure you have NODE JS and ANDROID_HOME paths set as expected and do restart the appium server everytime you want to run your script

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. hello Aravind G
    FAILED CONFIGURATION: @BeforeTest setUp
    org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: com.sec.android.app.popupcalculator/com.sec.android.app.popupcalculator.Calculator never started. Current: com.sec.android.app.popupcalculator/.Calculator) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 42.41 seconds
    can u please help me out

    ReplyDelete
    Replies
    1. Rerun test when you face above error. Try 2 to 3 times.

      Delete
  6. Hello Aravind,
    Getting error while run ANDROID command on CMD

    xcopy' is not recognized as an internal or external command operable program or batch file

    ReplyDelete
  7. Hello Aravind,
    Getting error:
    (Original error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity) (WARNING: The server did not provide any stacktrace information)

    ReplyDelete
  8. thank you so much for this wonderful tutorial.

    ReplyDelete
  9. Hi Aravind,

    I am ruining my first android script.I have done setup all 12 steps without any errors.
    But I am getting error like "A new session could not be created. (Original error: Android devices must be of API level 17 or higher. Please change your device to Selendroid or upgrade Android on your device.) (WARNING: The server did not provide any stacktrace information)".

    I am using samusung galaxy grand mobile with andoid 4.1.2 version.

    Could you please help me.

    ReplyDelete
    Replies
    1. I think you have not read 1st step properly at http://software-testing-tutorials-automation.blogspot.in/2015/09/what-is-appium-why-need-appium.html

      Appium supports only Android 17+ API level versions. You can use appium if your phone contain Android 4.2 or greater version.

      Delete
  10. Hi Aravid G
    I am getting an error: unhandled error , ENOENT NO SUCH FILE OR DIRECTORY 'D:\SDK;\BUILD-TOOLS;'
    Please reply me how resolve this error

    ReplyDelete
  11. Hi Aravind G
    When i am executing my first test, i am getting an error is " error: Unhandled error: Error: ENOENT, no such file or directory 'D:\SDK;\build-tools'".
    Please help me on how to resolve this error.

    ReplyDelete
    Replies
    1. Hi Srinu, getting the same error. Did you resolve this issue?
      Thanks!

      Delete
  12. Hi, Aravind, Thanks I have learn lots from you.

    I know I have done something wrong, for my running your code does not success. The following is what I get:

    FAILED CONFIGURATION: @BeforeTest setUp
    org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Command failed: C:\Windows\system32\cmd.exe /s /c "G:\Android\platform-tools\adb.exe -s 0123456789 install "G:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk""
    - waiting for device -
    ) (WARNING: The server did not provide any stacktrace information)

    I don't where I am wrong, I am trapped here, could move forward.

    Please help me out?

    Mak

    ReplyDelete
  13. Hi Aravind,

    I use Appium+Java+Eclipse, and installed all staff, check environment with command Appium-doctor in dos window, all environment set correctly.

    My code is below:
    package androidTestSuite;

    import java.net.MalformedURLException;
    import java.net.URL;

    import io.appium.java_client.AppiumDriver;
    import io.appium.java_client.android.AndroidDriver;
    import io.appium.java_client.remote.MobileCapabilityType;

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

    public class TestDriver {

    public TestDriver() {
    // TODO Auto-generated constructor stub
    }


    public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.out.println("test begin:");
    System.out.println("-----------------------");
    WebDriver driver;
    //
    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.3");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");


    capabilities.setCapability(MobileCapabilityType.APP,"C:\\SeleniumWebDriver\\LindaMobile\\AutotaskLiveMobile.apk");

    capabilities.setCapability(MobileCapabilityType.APP_PACKAGE, "com.autotask");

    capabilities.setCapability(MobileCapabilityType.APP_ACTIVITY, ".view.Main");
    URL url;

    try {
    url = new URL("http://127.0.0.1:4723/wd/hub");
    driver = new RemoteWebDriver(url, capabilities);
    driver.get("https://ch-qanext.autotask.com/");
    } catch (MalformedURLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }



    System.out.println("end:");


    }

    }

    when I run, it reported below error, can you help me out?

    test begin:
    -----------------------
    Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: Command failed: C:\Windows\system32\cmd.exe /s /c "java -version"
    'java' is not recognized as an internal or external command,
    operable program or batch file.
    ) (WARNING: The server did not provide any stacktrace information)
    Command duration or timeout: 146 milliseconds
    Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:16:47'
    System info: host: 'Linda-PC', ip: '172.16.20.71', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
    Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    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:605)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:155)
    at androidTestSuite.TestDriver.main(TestDriver.java:43)

    Thanks,
    Lily

    ReplyDelete
    Replies
    1. Seems Java environmental variables are not configured. Run >> java -version in command prompt to confirm.

      Delete
    2. Hi Lily,
      Where should I include the code to do test in the above code you posted.
      Please help me out.. Out of time

      Delete
  14. I have an error "Error: Could not find or load main class org.testng.remote.RemoteTestNG". What I have to do?

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. [TestNGClassFinder] Warning: Can't link and determine methods of class testproject.ClassOne
    [[TestNGClassFinder]] Unable to read methods on class testproject.ClassOne - unable to resolve class reference org/openqa/selenium/Capabilities
    [TestNG] Running:
    C:\Users\User\AppData\Local\Temp\testng-eclipse--916188786\testng-customsuite.xml


    What I have to do?

    ReplyDelete
  17. Hi,
    I tried to run the code. I was able to launch the application in the real time device(i.e @BeforeClass got executed ) but after that I was not able to execute the other methods(i.e @Test). It does not give any error. appium waits for some time and then it closes the app saying that “no further instructions were recieved so closing Appium”. Can you please help me.

    ReplyDelete
  18. Thanks for the tutorial Aravind..Its really helpful..Really happy to execute my first mobile test..

    ReplyDelete
  19. Thanks for the tutorial.. Its really helpful.. Happy to execute my first mobile test.

    ReplyDelete
  20. These tutorials are excellent.

    ReplyDelete
  21. FAILED CONFIGURATION: @BeforeClass firstTestInit
    org.openqa.selenium.UnsupportedCommandException: That URL did not map to a valid JSONWP resource
    Command duration or timeout: 211 milliseconds
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'

    @BeforeClass
    public void firstTestInit() throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appPackage", "com.android.calculator2");
    capabilities.setCapability(CapabilityType.VERSION, "6.0");
    capabilities.setCapability("platformVersion", "23");
    // capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
    capabilities.setCapability("platformName", "Android");
    //capabilities.setCapability(CapabilityType.PLATFORM,"Windows");
    capabilities.setCapability("deviceName", "AMWKCA49BALZGEEU");
    capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
    webDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/ws/hub"), capabilities);

    }

    ReplyDelete
  22. @BeforeClass
    public void firstTestInit() throws MalformedURLException {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("appPackage", "com.android.calculator2");
    capabilities.setCapability(CapabilityType.VERSION, "6.0");
    capabilities.setCapability("platformVersion", "23");
    // capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
    capabilities.setCapability("platformName", "Android");
    //capabilities.setCapability(CapabilityType.PLATFORM,"Windows");
    capabilities.setCapability("deviceName", "AMWKCA49BALZGEEU");
    capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");
    webDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/ws/hub"), capabilities);

    }
    FAILED CONFIGURATION: @BeforeClass firstTestInit
    org.openqa.selenium.UnsupportedCommandException: That URL did not map to a valid JSONWP resource
    Command duration or timeout: 211 milliseconds
    Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'

    ReplyDelete
  23. FAILED CONFIGURATION: @BeforeTest setUp
    java.lang.NoClassDefFoundError: com/google/common/base/Function
    error is thrown while trying to execute the mentioned program.

    Please let me know how to proceed.

    ReplyDelete
  24. Hi i am getting the below error i gave the IP in the program and in appium server as the same but still it shows me the error. can anyone help me???
    [TestNG] Running:
    C:\Users\shanmuga\AppData\Local\Temp\testng-eclipse-102939355\testng-customsuite.xml

    FAILED: call
    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.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
    System info: host: 'shanmugam', ip: '192.168.1.3', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_101'
    Driver info: driver.version: AndroidDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:51)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
    at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:47)
    at io.appium.java_client.AppiumDriver.(AppiumDriver.java:114)
    at io.appium.java_client.AppiumDriver.(AppiumDriver.java:132)
    at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:97)
    at Appiumpackage.call(Appiumpackage.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)

    ReplyDelete
  25. Hi I'm getting error like below :
    java.lang.ExceptionInInitializerError
    at org.apache.http.conn.ssl.SSLSocketFactory.(SSLSocketFactory.java:151)
    at org.openqa.selenium.remote.HttpCommandExecutor.getClientConnectionManager(HttpCommandExecutor.java:94)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:112)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:89)
    at com.moduletry.dev4.appiumsimpletest1.ExampleUnitTest.setUp(ExampleUnitTest.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.TestRunner.beforeRun(TestRunner.java:647)
    at org.testng.TestRunner.run(TestRunner.java:615)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
    at org.testng.TestNG.run(TestNG.java:1018)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:122)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    Caused by: java.lang.RuntimeException: Stub!
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:14)
    at org.apache.http.conn.ssl.AbstractVerifier.(AbstractVerifier.java:60)
    at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:43)
    at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:45)
    ... 31 more

    ReplyDelete
  26. Hi, I'm getting error like below

    java.lang.ExceptionInInitializerError
    at org.apache.http.conn.ssl.SSLSocketFactory.(SSLSocketFactory.java:151)
    at org.openqa.selenium.remote.HttpCommandExecutor.getClientConnectionManager(HttpCommandExecutor.java:94)
    at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:112)
    at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:89)
    at com.moduletry.dev4.appiumsimpletest1.ExampleUnitTest.setUp(ExampleUnitTest.java:50)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
    at org.testng.TestRunner.beforeRun(TestRunner.java:647)
    at org.testng.TestRunner.run(TestRunner.java:615)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
    at org.testng.TestNG.run(TestNG.java:1018)
    at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:122)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    Caused by: java.lang.RuntimeException: Stub!
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:14)
    at org.apache.http.conn.ssl.AbstractVerifier.(AbstractVerifier.java:60)
    at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:43)
    at org.apache.http.conn.ssl.AllowAllHostnameVerifier.(AllowAllHostnameVerifier.java:45)
    ... 31 more

    ReplyDelete
  27. Hi,

    I am not able to run my appium test. It shows error org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: 'java -version' failed. Error: spawn ENOENT)
    I am using Android 6.0 API level 23.
    Also I am using latest Appium. Please suggest.

    ReplyDelete
  28. Hello ,

    I have tried running the same calculator code provided with packagename,launcher activity changes (Changed all the values specific to device).
    Iam facing below issue.Unable to launch the app on device .
    Device details: S4-4.4.2 OS

    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.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
    System info: host: 'PHCHBS-L93438', ip: '10.133.61.162', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_13'
    Driver info: driver.version: RemoteWebDriver
    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.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'


    ReplyDelete
  29. With the latest version of everything I had to make one minor change to get the test script working. The class name for the result widget has changed, so the proper line should now be this:
    String result = driver.findElement(By.className("android.widget.TextView")).getText();

    ReplyDelete
  30. Hi,
    Why have we added java client dependency in pom. Where as no where in the code are we using it. We have not even imported the it's libraries.

    ReplyDelete
  31. Throws an error like, No main class. When tryind to run it as java application

    ReplyDelete
  32. org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: ENOENT: no such file or directory, scandir '/home/user/Documents/Appium/tools/build-tools' (WARNING: The server did not provide any stacktrace information)

    --in ubuntu am getting error like above

    ReplyDelete
  33. Apr 11, 2018 3:56:31 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS

    ReplyDelete
  34. Received the below error

    Apr 11, 2018 3:56:31 PM org.openqa.selenium.remote.ProtocolHandshake createSession
    INFO: Detected dialect: OSS

    ReplyDelete
  35. Hi,

    I copied the code
    ===
    import org.testng.annotations.Optional;
    import org.testng.annotations.Parameters;
    import org.testng.annotations.Test;

    import com.ancestrydna.automation.helix.basesetup.TestNGTestBase;
    import com.ancestrydna.automation.helixrerun.Retry;

    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.DesiredCapabilities;

    //import org.openqa.selenium.remote.CapabilityType;
    //import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;
    import org.testng.annotations.AfterTest;
    import org.testng.annotations.BeforeTest;
    import org.testng.annotations.Test;

    public class MyLogin {

    WebDriver driver;
    @BeforeTest
    public void setUp() throws MalformedURLException {
    // Created object of DesiredCapabilities class.
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("deviceName", "LocalEmulator");
    capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");

    // Set android VERSION desired capability. Set your mobile device's OS version.
    capabilities.setCapability(CapabilityType.VERSION, "4.4.2");

    // Set android platformName desired capability. It's Android in our case here.
    capabilities.setCapability("platformName", "Android");

    // Set android appPackage desired capability. It is
    // com.android.calculator2 for calculator application.
    // Set your application's appPackage if you are using any other app.
    capabilities.setCapability("appPackage", "com.android.calculator2");

    // Set android appActivity desired capability. It is
    // com.android.calculator2.Calculator for calculator application.
    // Set your application's appPackage if you are using any other app.
    capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

    // Created object of RemoteWebDriver will all set capabilities.
    // Set appium server address and port number in URL string.
    // It will launch calculator app in android device.
    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
    }

    @Test
    public void Sum() {
    // Click on DELETE/CLR button to clear result text box before running test.
    driver.findElements(By.xpath("//android.widget.Button")).get(0).click();

    // Click on number 2 button.
    driver.findElement(By.name("2")).click();

    // Click on + button.
    driver.findElement(By.name("+")).click();

    // Click on number 5 button.
    driver.findElement(By.name("5")).click();

    // Click on = button.
    driver.findElement(By.name("=")).click();

    // Get result from result text box.
    String result = driver.findElement(By.className("android.widget.EditText")).getText();
    System.out.println("Number sum result is : " + result);

    }

    @AfterTest
    public void End() {
    driver.quit();
    }
    }
    ===
    and I am getting following error
    The import org.openqa.selenium.remote.DesiredCapabilities cannot be resolved

    ReplyDelete