无法使用 Appium 为 IOS 生成的代码 运行 量角器脚本它说 findelement 不是函数

Cannot run protractor scripts using code generated by Appium for IOS it says that findelement is not a function

我想使用 Ipad Air 模拟器、appium 和量角器对 Angular JS 站点进行自动化测试,但问题是我无法 运行 正确地编写脚本.

这是我的配置文件

​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://10.0.22.82:4180/jws/fetablet_dev_T1000',

  frameworks:[
    'mocha',
    'chai'
  ],

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.get("0.22.82:4180/jws/fetablet_dev_T1000");


 browser.driver.findelement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");


});

});

虽然 运行ning protractor.config.js 我有以下错误并且我的测试失败了,我如何识别元素?

​Using the selenium server at http://0.0.0.0:4723/wd/hub
[launcher] Running 1 instances of WebDriver
Started
F

Failures:​​
1) my app should make the login test
  Message:
    Failed: browser.driver.findelement is not a function
  Stack:
    TypeError: browser.driver.findelement is not a function
        at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:26:17)
        at /usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:96:23
        at new Promise (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1043:7)
        at controlFlowExecute (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:82:18)
        at TaskQueue.execute_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
        at TaskQueue.executeNext_ (/usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2697:25
        at /usr/local/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
        at process._tickCallback (internal/process/next_tick.js:103:7)
    From: Task: Run it("should make the login test") in control flow
        at Object.<anonymous> (/usr/local/lib/node_modules/protractor/node_modules/jasminewd2/index.js:81:14)
    From asynchronous test: 
    Error
        at Suite.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:15:1)
        at Object.<anonymous> (/Users/qaquod/Development/qa/qa_fetablet/testsuite/test3.js:13:1)
        at Module._compile (module.js:413:34)
        at Object.Module._extensions..js (module.js:422:10)
        at Module.load (module.js:357:32)
        at Function.Module._load (module.js:314:12)
1 spec, 1 failure
Finished in 0.03 seconds
[launcher] 0 instance(s) of WebDriver still running
​
[launcher] safari #01 failed 1 test(s)
[launcher] overall: 1 failed spec(s)
[launcher] Process exited with error code​ 1​

您可能肯定想更改此设置:

browser.driver.findelement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");

browser.driver.findElement(by.xpath("//UIAApplication[1]/UIAWindow[2]/UIAScrollView[1]/UIAScrollView[1]/UIAWebView[1]/UIATextField[1]")).sendKeys("RET02");

                   ^ //E instead of e