无法使用Leadfoot / Intern找到BP路径

时间:2015-06-09 10:01:51

标签: ios intern leadfoot

使用Intern JS和WebDirver与Appium 1.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“检查器”我已经确认了文本输入框元素的Xpath是:

"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"

有人可以建议我哪里出错吗?

1 个答案:

答案 0 :(得分:2)

看起来我的Mac上的Appium Inspector工具正在重复部分路径?

.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")

以粗体删除重复的元素(最终的UIATextField [1])....

.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")

它有效。

感谢Appium Inspector。非常感谢。