简体   繁体   中英

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();

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM