我想使用Ipad Air模拟器,appium和量角器自动化我对Angular JS站点的测试但是测试无法成功通过的问题,它告诉我元素无法找到并且我确信xpath是由appium生成的。
这是我的配置文件
exports.config = {
allScriptsTimeout: 600000,
seleniumAddress: 'http://0.0.0.0:4723/wd/hub',
specs: [
'testsuite/test3.js'
],
capabilities: {
browserName: 'safari',
'appium-version': '1.4.13',
platformName: 'iOS',
platformVersion: '9.3',
deviceName: 'iPad Air'
},
chromeOnly: false,
baseUrl: 'http://urlofmyapp',
frameworks:[
'jasmine'
],
mochaOpts: {
defaultTimeoutInterval:1000000
}
};
我的test3.js文件包含:
"use strict";
var wd = require("wd");
var chai = require("chai");
var chaiAsPromised = require("chai-as-promised");
chai.use(chaiAsPromised);
var expect = chai.expect;
chai.should();
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
describe('my app', function() {
it('should make the login test',function() {
var desired = {
browserName: 'safari',
platformName:'iOS',
name:"This is an example for login test"
}
browser.ignoresynchronization=true;
browser.get("theurlofmyapp");
browser.driver.findElement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");
});
});
运行时出现错误
量角器protractor.config.js
答案 0 :(得分:1)
将browser.driver.findElement
更改为browser.findElement