简体   繁体   English

Appium iOS自动化Node.js脚本

[英]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. 我正在尝试使用Appium(来自终端)和nodejs脚本在真实设备上自动化iOS本机应用程序。 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. 我能够安装和启动该应用程序,直到该应用程序的第一个屏幕,但是之后,除了睡眠之外,没有其他nodejs脚本被执行。 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. 请在这里告诉我我是否使用正确的nodejs命令。

NB:The same nodejs script was working fine for android automation 注意:相同的nodejs脚本对于Android自动化运行良好

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: 尝试使用Appium应用检查器获取元素的xpath:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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