使用实习生JS和WebDirver与Appium1.4.1通信,我有一个简单的功能测试,其中一部分应该会在我们的iOS应用程序的登录屏幕上找到一个文本输入框,点击它并输入用户的登录名:
define([
'intern!object',
'intern/chai!assert',
'require'
], function (registerSuite, assert, require) {
registerSuite({
name: 'Suite Name',
'Login Screen': function () {
return this.remote
.setFindTimeout(50000)
.findByXpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]")
.tap()
.type('student1@demo.com')
.end()
.then(function (pagetitle) {
assert.strictEqual(pagetitle, 'DEMO COLLEGE',
'Should land on app dashboard with school title displayed');
});
}
});
});当使用intern-runner执行时,一切似乎都很顺利,Appium启动我们的应用程序并等待我的输入--但无论我怎么尝试,我都找不到我需要使用Leadfoot的findByXpath输入的元素:
$ intern-runner config=tests/appium
Listening on 0.0.0.0:9000
Starting tunnel...
Initialised iOS on MAC 8.1
Test main - Suite Name - Login Screen FAILED on iOS on MAC 8.1:
NoSuchElement: [POST http://[appium-server-address]:4723/wd/hub/session/80e20453-452e-4181-8713-4f9e0cfa427f/element / {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"}] An element could not be located on the page using the given search parameters.
at Server._post <../../.nvm/v0.10.35/lib/node_modules/intern/node_modules/leadfoot/Server.js:68:9>使用Appium的GUI“检查器”,我已经确认text-input-box元素的Xpath是:
"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"有没有人能告诉我哪里出错了?
发布于 2015-06-09 19:03:03
看起来我的Mac上的Appium Inspector工具正在复制路径的一部分?
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")去掉重复的粗体元素(最后的UIATextField1) ...
.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")而且它是有效的。
谢谢Appium Inspector。非常感谢。
https://stackoverflow.com/questions/30728906
复制相似问题