【问题标题】:Unable to findByXpath using Leadfoot / Intern无法使用 Leadfoot / Intern 找到 ByXpath
【发布时间】:2023-03-18 07:46:01
【问题描述】:

使用 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“检查器”,我已经确认到 text-input-box 元素的 Xpath 是:

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

谁能建议我哪里出错了?

【问题讨论】:

    标签: ios intern leadfoot


    【解决方案1】:

    看起来我 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 检查员。非常感谢。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多