nativescript-dev-appium icon indicating copy to clipboard operation
nativescript-dev-appium copied to clipboard

Run Tests on Android Real Device

Open coderaven opened this issue 5 years ago • 1 comments

Platform: Nativescript Angular

After the setup and initial test code generated, and editing the appium.capabilities.json to add my emulator properly, I was able to succesfully run my tests to the emulator.

However, I need to be able to run the tests to a real device connected via USB (Android).

  • Debugging is on

I added my test device details on the capabilities json as well, so the appium.capabilities.json looks like this now:

{
    "realme": {
        "platformName": "Android",
        "deviceName": "RMX1851",
        "udid": "a53b7a83",
        "noReset": false,
        "fullReset": false,
        "app": ""
    },
 "pixel": {
        "platformName": "Android",
        "platformVersion": "29",
        "deviceName": "Pixel_3a_API_29",
        "avd": "emulator-5554",
        "lt": 60000,
        "newCommandTimeout": 720,
        "noReset": false,
        "fullReset": false,
        "app": ""
    }

One for emulator and one for actual device. The emulator works just fine when running: npm run e2e android

However, when I connect my actual device and run the same command. It will not be shown in the list of devices and the command defaults to the emulator as a fallback.

I managed to get it to try to run to my actual device by using this command instead: npm run e2e -- --runType=realme --ignoreDeviceController --relaxedSecurity

I can confirm that it has now successfully installed the appium service on my device, but cannot move past running my app for testing. With these errors outputted:

Capabilities found at: ********
Automation name set to: UIAutomator1 
To change automation name, you need to set it in appium capabilities!
Available applications:  ["platforms/android/app/build/outputs/apk/debug/app-debug.apk"]
Pick first application:   "platforms/android/app/build/outputs/apk/debug/app-debug.apk"
Application full path: ****\platforms\android\app\build\outputs\apk\debug\app-debug.apk
Platform version is missing! It would be better to set it in order to use the correct device!     
Default device:  { name: 'RMX1851',
  platform: 'android',
  config: { density: undefined, offsetPixels: undefined } }
Server args:   ["-p","4723","--log-level","info","--relaxed-security"]
Started Server!
  sample scenario
before loging . . . .
Session info:  
undefined
Appium settings:  
Current version of appium doesn't support appium settings! 
{"message":"[execute(\"mobile: shell\",{\"command\":\"wm\",\"args\":[\"density\"]})] Not JSON response","data":"The URL '/wd/hub/session/execute' did not map to a valid resource"}
Retry launching appium driver!
Appium driver is NOT started! 
(node:10604) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated

Anyone has an idea how to run the tests properly on real devices? (Android / IOS).

coderaven avatar Mar 16 '20 05:03 coderaven

:iphone: On Android

📍 Real Device: Set deviceToken property to the appium.capabilities to Device Identifier

$ ns devices
Connected devices & emulators
Searching for devices...
┌───┬──────────────┬──────────┬───────────────────┬────────┬───────────┬─────────────────┐
│ # │ Device Name  │ Platform │ Device Identifier │ Type   │ Status    │ Connection Type │
│ 1 │ nyc4xlwifiyy │ Android  │ R52N94D54BK       │ Device │ Connected │ USB             │
└───┴──────────────┴──────────┴───────────────────┴────────┴───────────┴─────────────────┘
  • [ ] Edit appium.capabilities.json file
   "android29": {
        "platformName": "Android",
        "platformVersion": "29",
        "deviceToken": "R52N94D54BK",
        "lt": 60000,
        "newCommandTimeout": 720,
        "noReset": true,
        "fullReset": false,
        "app": ""
    },
  • [ ] Run the test
$ npm run e2e -- --runType android29

:iphone: On iPhone

It's more complicated since you have to Sign and Install the WebDriverAgent first and then run the test.

I am trying to do the same but I am having an issue with https://github.com/NativeScript/nativescript-dev-appium/issues/287#issue-758037171

setrar avatar Dec 06 '20 22:12 setrar