Skip to content

Run Tests on Android Real Device #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
coderaven opened this issue Mar 16, 2020 · 1 comment
Open

Run Tests on Android Real Device #284

coderaven opened this issue Mar 16, 2020 · 1 comment

Comments

@coderaven
Copy link

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).

@setrar
Copy link

setrar commented Dec 6, 2020

📱 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

📱 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 #287 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants