gpt4 book ai didi

ios - 如何从 Sencha Touch App 识别 UI 元素以使用 Appium 进行测试?

转载 作者:行者123 更新时间:2023-11-29 12:05:19 26 4
gpt4 key购买 nike

我在使用此 Node.js 库的最新版本 (0.4.0) 编写客户端测试时遇到问题:https://github.com/admc/wd .我正在使用 Sencha Touch 2.4。

我可以让 selenium webdriver 连接到 Appium 应用程序(v 1.4.13)服务器,这反过来似乎在我指定的 iPhone 模拟器中正确加载我的 Sencha Touch 应用程序。我可以使用 Appium Inspector 检查元素。

但是,在编写测试时,我无法在应用的初始 View 中识别任何 UI 元素。在 Sencha Architect 中,我将按钮组件 id 属性设置为 primary-login-container-new-account-button

例如,对于以下每种情况,似乎从未找到该元素。恐怕是 Sencha 动态生成元素是我找不到元素的原因。然而,我读到 Selenium 是用于 UI 测试 Sencha 应用程序的一个选项,所以它一定很容易实现吧?我的项目也包含在 Cordova 中。

1.

[...]
it("should be able to click on Create New Account button1", function () {
return driver
.elementById('primary-login-container-new-account-button')
.text().should.become('Create New Account');
});
// Error: [elementById("primary-login-container-new-account-button")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.

2.

it("should be able to click on Create New Account button2", function () {
return driver
.elementByAccessibilityId('primary-login-container-new-account-button')
.text().should.become('Create New Account');
});
// Error: [elementByAccessibilityId("primary-login-container-new-account-button")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.

3.

it("should be able to click on Create New Account button3", function () {
return driver
.elementByIdOrNull('primary-login-container-new-account-button', function(err, element) {
});
});
// returns element and err as null

4.

it("should be able to click on Create New Account button4", function () {
return driver
.elementByCssSelector('#primary-login-container-new-account-button')
.text().should.become('Create New Account');
});
// Error: [elementByCssSelector("#primary-login-container-new-account-button")] Error response status: 9, , UnknownCommand - The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource. Selenium error: Invalid locator strategy: css selector

5.

it("should be able to click on Create New Account button5", function () {
return driver
.elementByName('createUserAccountButton')
.text().should.become('Create New Account');
});
// Error: [elementByName("createUserAccountButton")] Error response status: 7, , NoSuchElement - An element could not be located on the page using the given search parameters. Selenium error: An element could not be located on the page using the given search parameters.

6.

 it("should be able to click on Create New Account button6", function () {
return driver
.waitForElementById('#primary-login-container-new-account-button', 30000)
.text().should.become('Create New Account');
});
// Error: [waitForElementById("#primary-login-container-new-account-button",30000)] Element condition wasn't satisfied!
[...]

最佳答案

由于您的应用是在 Cordova 上构建的,因此只是一个试用版,请在 Chrome/Safari 上使用检查设备检查元素 primary-login-container-new-account-button。在您能够访问它之前,您必须在检查时找到一些属性,例如 cssclass。话虽如此,如果您能够使用 Chrome/Safari 检查它们,那么您正在查看一个 webview,您必须将其上下文切换到 Webview 才能访问此处的元素。

由于元素是由 Sencha 动态生成的,因此也可能为这些属性分配了一些随机键值。在这种情况下,您必须指定生成的值才能访问您的 View 元素。

Note : It would be great to look at a screenshot of Chrome Inspected elements on the view from your application along with the Appium Inspector screenshot corresponding to the same.

关于ios - 如何从 Sencha Touch App 识别 UI 元素以使用 Appium 进行测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35245657/

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