user3323241
user3323241

Reputation: 479

Appium ios automation nodejs scripts

I am trying to automate an iOS native app on a real device using Appium(from terminal) and nodejs script. I am able to install and launch the app till the first screen of the app but after that no nodejs scripts other than sleep is getting executed. I need to type in some text in the the textfields present in the screen but the cursor is getting pointed and nothing happens after that. Please tell me whether I am using the correct nodejs commands here.

NB:The same nodejs script was working fine for android automation

var wd = require("wd");
require('colors');
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
var capture = require("capture");
chai.use(chaiAsPromised);
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;

var host, port, username, accessKey, desired;
console.log("Print 1");
var desired = {
    'browserName': '',
    'automationName': 'Appium',
    'platformName': 'iOS',
    'platformVersion': '6.1.4',
    'deviceType':'iPhone',
    'deviceName' :'xxx’s iPhone',
    // 'nativeInstrumentsLib' : 'true',

    'app': "/Users/Desktop/xxx_my_appname-358.ipa",

    'bundleId': 'com.xxx.myapp',
    'deviceOrientation': 'portrait'

};
host = "localhost";
port = 4723;


// Instantiate a new browser session
var browser = wd.promiseChainRemote(host, port, username, accessKey);

// See whats going on
browser.on('status', function (info) {
    console.log(info.cyan);
});
browser.on('command', function (meth, path, data) {
    console.log(' > ' + meth.yellow, path.grey, data || '');
});

// Run the test
browser.init(desired)
//    then(function () {
browser
    //  yield.elementByName("userNameTextField").click()
    .sleep(30000) // **** WORKING FINE**
        .elementByName('User Id').type('userID') // ** NOT WORKING **
        .elementByName('Next').click() // ** NOT WORKING **
        .elementByName('Password').type('password') // ** NOT WORKING *

    .sleep(30000) // **** WORKING FINE**
    .fin(function () {
        return browser
            .sleep(30000)
            .quit()
        console.log("inside click");
//            });
    })
    .catch(function (err) {
        console.log(err);
        console.log("Entering into error Catch...")
        throw err;
    })
    .done();

Upvotes: 0

Views: 1245

Answers (1)

Geekdad
Geekdad

Reputation: 73

Try using the Appium app inspector to get the xpath of the elements:

.elementByXPath("//UIAApplication[1]/UIAWindow[1]/UIATextField[1]").sendKeys("userID")

.elementByXPath("//UIAApplication[1]/UIAWindow[1]/UIASecureTextField[1]").sendKeys("password")

Upvotes: 1

Related Questions