无法使用 Appium 为 IOS 生成的代码运行量角器脚本,它说 findelement 不是函数
Posted
技术标签:
【中文标题】无法使用 Appium 为 IOS 生成的代码运行量角器脚本,它说 findelement 不是函数【英文标题】:Cannot run protractor scripts using code generated by Appium for IOS it says that findelement is not a function 【发布时间】:2016-08-05 19:05:50 【问题描述】:我想使用 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");
);
);
在运行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
【问题讨论】:
【参考方案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
【讨论】:
感谢您的回答,它为我更改了错误,但仍然无法正常工作,但它告诉我无法找到该元素。问题是网站打开而不是立即关闭并且ipad模拟器崩溃! @Emna :您可以将其作为单独的线程发布,这似乎是其他问题。 :) 是的,这是另一个,我会接受这个,然后我开了一个新问题:***.com/questions/36630553/…以上是关于无法使用 Appium 为 IOS 生成的代码运行量角器脚本,它说 findelement 不是函数的主要内容,如果未能解决你的问题,请参考以下文章
无法使用适用于 iOS 混合应用程序的 appium 检查作为背景图像存在的元素
无法在真实设备上使用 Appium 在 iOS hyprid 应用程序自动化中识别 WEBVIEW 中的元素