1

I'm using selenium + maven + cucumber + testng + appium for mobile ui test. Also I'm running this cases on the real device. But app's launching two times;

Mar 03, 2020 5:56:11 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
Mar 03, 2020 5:56:37 PM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C

And then i see the following error message;

Scenario: [1.0] Check Incoming Payment Types [90m# src/test/resources/features/Android/Payment.feature:6[0m
    [31mGiven [0m[31modeal app is launched[0m                [90m# PaymentFlow.launchedOdealApp()[0m
      [31morg.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
      Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
      System info: host: 'admins-Mac-mini.local', ip: 'fe80:0:0:0:14b1:249d:6e8e:379f%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.3', java.version: '1.8.0_231'
      Driver info: io.appium.java_client.android.AndroidDriver
      Capabilities {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, databaseEnabled: false, desired: {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, deviceName: TestDevice-1, noReset: true, platformName: android, platformVersion: 7.1.1, udid: ZH33D2543D}, deviceApiLevel: 25, deviceManufacturer: motorola, deviceModel: Moto E (4) Plus, deviceName: ZH33D2543D, deviceScreenDensity: 320, deviceScreenSize: 720x1280, deviceUDID: ZH33D2543D, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2, platform: LINUX, platformName: Android, platformVersion: 7.1.1, statBarHeight: 48, takesScreenshot: true, udid: ZH33D2543D, viewportRect: {height: 1136, left: 0, top: 48, width: 720}, warnings: {}, webStorageEnabled: false}
      Session ID: 9b91b01c-08bd-4b7a-a65e-4e09e5a7fcf5
      *** Element info: {Using=id, value=login}
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
        at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
        at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
        at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
        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.findElement(RemoteWebDriver.java:323)
        at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61)
        at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
        at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:372)
        at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:69)
        at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1)
        at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1)
        at org.openqa.selenium.By$ById.findElement(By.java:188)
        at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
        at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)
        at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
        at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
        at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
        at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
        at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:641)
        at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:638)
        at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
        at com.odealMobile.PaymentFlow.launchedOdealApp(PaymentFlow.java:44)
        at ✽.Given odeal app is launched(src/test/resources/features/Android/Payment.feature:7)
      [0m
    [36mWhen [0m[36muser log in to Odeal successfully[0m     [90m# PaymentFlow.loginTheApp()[0m
    [36mAnd [0m[36mClicks on New Payment button[0m           [90m# PaymentFlow.clickNewPayment()[0m
    [36mAnd [0m[36mEnter Price to Opened Page[0m             [90m# PaymentFlow.enterPrice()[0m
    [36mAnd [0m[36mClicks on Get Paid button[0m              [90m# PaymentFlow.clickPaidButton()[0m
    [36mThen [0m[36mAll Payment Types will be Appeared[0m    [90m# PaymentFlow.checkPaymentTypes()[0m

[31mFailed scenarios:[0m
[31msrc/test/resources/features/Android/Payment.feature:6 [0m# Scenario: [1.0] Check Incoming Payment Types

1 Scenarios ([31m1 failed[0m)
6 Steps ([31m1 failed[0m, [36m5 skipped[0m)
0m54.617s

org.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'admins-Mac-mini.local', ip: 'fe80:0:0:0:14b1:249d:6e8e:379f%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.3', java.version: '1.8.0_231'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, databaseEnabled: false, desired: {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, deviceName: TestDevice-1, noReset: true, platformName: android, platformVersion: 7.1.1, udid: ZH33D2543D}, deviceApiLevel: 25, deviceManufacturer: motorola, deviceModel: Moto E (4) Plus, deviceName: ZH33D2543D, deviceScreenDensity: 320, deviceScreenSize: 720x1280, deviceUDID: ZH33D2543D, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2, platform: LINUX, platformName: Android, platformVersion: 7.1.1, statBarHeight: 48, takesScreenshot: true, udid: ZH33D2543D, viewportRect: {height: 1136, left: 0, top: 48, width: 720}, warnings: {}, webStorageEnabled: false}
Session ID: 9b91b01c-08bd-4b7a-a65e-4e09e5a7fcf5
*** Element info: {Using=id, value=login}
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
    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.findElement(RemoteWebDriver.java:323)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:61)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:372)
    at io.appium.java_client.DefaultGenericMobileDriver.findElementById(DefaultGenericMobileDriver.java:69)
    at io.appium.java_client.AppiumDriver.findElementById(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElementById(AndroidDriver.java:1)
    at org.openqa.selenium.By$ById.findElement(By.java:188)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
    at io.appium.java_client.DefaultGenericMobileDriver.findElement(DefaultGenericMobileDriver.java:57)
    at io.appium.java_client.AppiumDriver.findElement(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.findElement(AndroidDriver.java:1)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
    at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:201)
    at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:641)
    at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:638)
    at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)
    at com.odealMobile.PaymentFlow.launchedOdealApp(PaymentFlow.java:44)
    at ✽.Given odeal app is launched(src/test/resources/features/Android/Payment.feature:7)


===============================================
Suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================

Actually i see opened app on the mobile device but my case does not run. I want to emphasize app opens two times. Firstly app opens and the home page is appeared and then it is closed. Then app opens second time and no case are running.

Mobile device that i've used for my test : Motorola Moto E(4) Plus , 7.1.1 Appium version 1.15.1

My Desired Capability Details :

 //Screen Classes Initialization
    public void setupCucumber () throws MalformedURLException {
         DesiredCapabilities cap = new DesiredCapabilities();
         cap.setCapability("deviceName", "TestDevice-1");
         cap.setCapability("automationName", "UiAutomator2");
         cap.setCapability("udid", "ZH33D2543D");
         cap.setCapability("platformName", "Android");
         cap.setCapability("platformVersion", "7.1.1");
         cap.setCapability("noReset", "true");
         //cap.setCapability("fullReset", "false");
         cap.setCapability("clearSystemFiles", "false");
         cap.setCapability("appPackage", "com.telera.merchant.stage.debug");
         cap.setCapability("appActivity", "com.telera.merchant.splash.SplashActivity");
         cap.setCapability("app", "/Users/busekaya/Desktop/app-stage-debug.apk");
         //cap.setCapability("autoAcceptAlerts", true);
         //cap.setCapability("path", "/Users/busekaya/Desktop/app-stage-debug.apk");
         driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap); //"http://127.0.0.1:4723/wd/hub\"
         driver.manage().timeouts().implicitlyWait(200, TimeUnit.SECONDS);
         wait = new WebDriverWait(driver, 200);
    }

Cucumber feature file ;

Feature: [1] All Scenarios About Payment    

  @buse2  
  Scenario: [1.0] Check Incoming Payment Types
     Given app is launched
     When  user log in successfully
     And Clicks on New Payment button
     And Enter Price to Opened Page
     And Clicks on the Get Paid button
     Then All Payment Types will be Appeared
2
  • Appium version? Commented Mar 3, 2020 at 23:12
  • appium version 1.15.1
    – Buse Kaya
    Commented Mar 4, 2020 at 7:38

2 Answers 2

0

Not sure if this might apply but I was running into the same issue, app was installed but Appium was terminating my sessions immediately saying it was

Caused by: java.lang.RuntimeException: Error while connecting UiAutomation

In my case, inspired on @DebanjanB answer, I reinstalled Appium's UiAutomator2 package and it worked perfectly right after

I ran this:

yarn add appium-uiautomator2-driver

If you're using npm, run this instead

npm i appium-uiautomator2-driver
-1

This error message...

[31morg.openqa.selenium.NoSuchSessionException: A session is either terminated or not started
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'admins-Mac-mini.local', ip: 'fe80:0:0:0:14b1:249d:6e8e:379f%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.3', java.version: '1.8.0_231'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, databaseEnabled: false, desired: {app: /Users/busekaya/Desktop/app..., appActivity: com.telera.merchant.splash...., appPackage: com.telera.merchant.stage.d..., automationName: UiAutomator2, clearSystemFiles: false, deviceName: TestDevice-1, noReset: true, platformName: android, platformVersion: 7.1.1, udid: ZH33D2543D}, deviceApiLevel: 25, deviceManufacturer: motorola, deviceModel: Moto E (4) Plus, deviceName: ZH33D2543D, deviceScreenDensity: 320, deviceScreenSize: 720x1280, deviceUDID: ZH33D2543D, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, noReset: true, pixelRatio: 2, platform: LINUX, platformName: Android, platformVersion: 7.1.1, statBarHeight: 48, takesScreenshot: true, udid: ZH33D2543D, viewportRect: {height: 1136, left: 0, top: 48, width: 720}, warnings: {}, webStorageEnabled: false}
Session ID: 9b91b01c-08bd-4b7a-a65e-4e09e5a7fcf5
*** Element info: {Using=id, value=login}

...implies that the AndroidDriver was unable to initiate/spawn a new Browsing Context through UiAutomator2.


Some more information from the server-side logs (Appium logs) would have helped us to analyze the issue in a better way. However, as you are using Appium v1.15.1, as per the discussion Error: The instrumentation process cannot be initialized this issue is observed with v1.11 and above, where as in version v1.10.1 there is no such issue. Presumably the server-side logs (Appium logs) would contain more details in the form of logs messages related to UiAutomator2 in similar lines:

[UiAutomator2] 'skipServerInstallation' is set. Attempting to use UIAutomator2 server from the device
[UiAutomator2] Waiting up to 60000ms for UiAutomator2 to be online...
[debug] [ADB] Creating ADB subprocess with args: ["-P",5037,"-s","emulator-5554","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[debug] [Instrumentation] android.util.AndroidException: INSTRUMENTATION_FAILED: io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner

The possible reason is, the UiAutomator2 is not installed on the device or may be the server installation is disabled explicitly.


Solution

A easier solution would have been to upgrade/downgrade UIAutomator2 inside Appium but you can't do that since UIAutomator2 has dependency on other modules.

So, the solution is to downgrade the whole Appium package. As an alternative, you can change the emulator/simulator on the device you are running your tests as well. At times uninstalling the Appium Settings app from the device and restarting the Appium process aslo solves the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.