gpt4 book ai didi

angularjs - 无法使用 Appium for IOS 生成的代码运行 Protractor 脚本,它表示 findelement 不是函数

转载 作者:太空宇宙 更新时间:2023-11-03 22:13:07 25 4
gpt4 key购买 nike

我想使用 Ipad Air 模拟器、appium 和 Protractor 自动对 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​

最佳答案

您可能确实想更改此设置:

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

关于angularjs - 无法使用 Appium for IOS 生成的代码运行 Protractor 脚本,它表示 findelement 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36619518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com