Skip to content

TypeError: Cannot read property 'token' of undefined issue #142

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

Closed
msaelices opened this issue Aug 1, 2018 · 4 comments
Closed

TypeError: Cannot read property 'token' of undefined issue #142

msaelices opened this issue Aug 1, 2018 · 4 comments
Assignees
Labels
Milestone

Comments

@msaelices
Copy link
Contributor

Which platform(s) does your issue occur on?

  • Android (not tested on iOS)
  • 8.0
  • emulator

Please, provide the following version numbers that your issue occurs with:

  • CLI: 4.1.1
  • Cross-platform modules: 4.1.1
  • Runtime(s): 3.4.1

Please, tell us how to recreate the issue in as much detail as possible.

Please reproduce the code below.

Is there any code involved?

Sample code:

    const appiumCaps = require('./appium.capabilities.json')[argv.runType];
    let args = {
      isSauceLab: argv.sauceLab || false,
      runType: argv.runType,
      appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
      appiumCaps: appiumCaps,
      verbose: argv.verbose || false,
    }

    AppiumDriver.createAppiumDriver(4723, args)
        .then(driver => run(driver))
        .then(() => console.log('Buh-Bye...'))
        .catch((err) => console.log(err));

Sample capabilities appium.capabilities.json file:

{
  "android23": {
    "automationName": "UiAutomator2",
    "platformName": "Android",
    "platformVersion": "6.0",
    "deviceName": "Android Emulator",
    "noReset": false,
    "avd": "Nexus_5X_API_27",
    "appPackage": "org.nativescript.nativescriptvueuitests",
    "appActivity": "com.tns.NativeScriptActivity"
  }
}

The error is caused because the createAppiumDriver() function calls to AppiumDriver.applyAdditionalSettings(args) which expects having an args.device argument, which is not present and it raises the Cannot read property 'token' of undefined.

But after that, the createAppliumDriver() function defines the args.device, so the sequence is:

    public static async createAppiumDriver(port: number, args: INsCapabilities) {
        ...
        if (!args.attachToDebug && !args.sessionId) {
            await AppiumDriver.applyAdditionalSettings(args);  // --> raises the error
        }
        ...
                        prepareApp(args);
                        if (!args.device) {
                            if (args.isAndroid) {
                                // --> but here we set the device (why later?) 
                                args.device = DeviceManager.getDefaultDevice(...);
                            } else {
                                args.device = DeviceManager.getDefaultDevice(args);
                            }
                        }

    }
msaelices added a commit to nativescript-vue/nativescript-vue-ui-tests that referenced this issue Aug 1, 2018
@SvetoslavTsenov SvetoslavTsenov self-assigned this Aug 4, 2018
@SvetoslavTsenov SvetoslavTsenov modified the milestone: 4.0.0 Aug 4, 2018
@SvetoslavTsenov
Copy link
Contributor

Hey @msaelices, indeed you are right and I have totally missed this scenario, basically we use another approach to do that where appium capabilites is provided like that:
./node_modules/.bin/mocha --opts mocha.opts --runType android24.sauce --sauceLab --appPath nativescript-ui-sidedrawer-demo-angular-release.apk
Anyway I will try to fix the issue in the next few days and release a new version of the plugin.

@SvetoslavTsenov
Copy link
Contributor

Hey @msaelices,
This issue is already resolved with [email protected]. Meanwhile, I have created a PR to nativescript-vue-ui-tests with e2e smoke tests.
Let me know if you have some questions to discuss.

@msaelices
Copy link
Contributor Author

@SvetoslavTsenov awesome! thanks!

@lock
Copy link

lock bot commented Aug 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants