【问题标题】:Appium ios automation nodejs scriptsAppium ios自动化nodejs脚本
【发布时间】:2015-09-29 07:42:48
【问题描述】:

我正在尝试使用 Appium(来自终端)和 nodejs 脚本在真实设备上自动化 iOS 本机应用程序。我能够安装和启动应用程序,直到应用程序的第一个屏幕,但之后除了睡眠之外没有执行任何 nodejs 脚本。我需要在屏幕上的文本字段中输入一些文本,但光标被指向,之后没有任何反应。请告诉我这里是否使用了正确的 nodejs 命令。

注意:相同的 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();

【问题讨论】:

    标签: ios node.js


    【解决方案1】:

    尝试使用 Appium 应用检查器获取元素的 xpath:

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

    【讨论】:

      猜你喜欢
      • 2018-09-15
      • 2021-01-24
      • 2016-07-29
      • 2014-09-03
      • 2017-01-20
      • 2020-01-14
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多