1

I'm looking to start automation of a mobile application. I went through Appium related articles and most of them suggest to use Appium with Javascript. I explored online and setup appium and my code thus far looks like:

var wd = require('wd');
//var app = require('sample-apps');


var remotes = {

local: {

    hostname: "localhost",
    port: 4723
}


}

var environment = remotes.local;

    desiredCaps = {


        deviceName: '4d86aed1',
        platformVersion: '5.1.1',
        platformName: 'Android',
        appPackage: 'delhivery.lastmile.dev',
        appActivity: 'delhivery.feapp.heavy.ui.LoginActivity'
        //app: 'http://appium.s3.amazonaws.com/ContactManager.apk'
    },
    driver = wd.remote(environment);
    driver.init(desiredCaps)



    //driver.elementById('etPhoneAL').click()

    driver.quit();

The code gets executed and I can view logs in the appium server session. As soon as I uncomment "driver.elementById('etPhoneAL').click()" the script fails instantaneously and no appium logs whatsoever!

Command to trigger script: "node simple-appium-android.js " And the error received:

/home/orgaone/Mobile-Appium/android/simple-appium-android.js:33
    driver.elementById('etPhoneAL').click()
                                   ^

TypeError: Cannot read property 'click' of undefined
    at Object.<anonymous> (/home/delhivery/Mobile-Appium/android/simple-appium-android.js:33:36)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)

I'm new with both Appium and Javascript so any suggestions how I can build a mobile testing framework (things like suggested practices, what framework to use etc.) using the aforementioned would be great!

0

The error suggests that driver.elementById('etPhoneAL') returns NULL. So there is problem in code in getting element and you should change your code to identify element and then you can click on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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