Ios 如何从Sencha Touch应用程序中识别UI元素,以便使用Appium进行测试?

Ios 如何从Sencha Touch应用程序中识别UI元素,以便使用Appium进行测试?,ios,cordova,selenium-webdriver,sencha-touch,appium,Ios,Cordova,Selenium Webdriver,Sencha Touch,Appium,使用此Node.js库的最新版本(0.4.0)编写客户端测试时遇到问题:。我正在使用Sencha Touch 2.4 我可以将selenium webdriver连接到Appium应用程序(v1.4.13)服务器,该服务器似乎可以在我指定的iPhone模拟器中正确加载我的Sencha Touch应用程序。我可以用Appium检查器检查元素 但是,在编写测试时,我无法识别应用程序初始视图中的任何UI元素。在Sencha Architect中,我已将按钮组件id属性设置为主登录容器新帐户按钮 例如,

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

我可以将selenium webdriver连接到Appium应用程序(v1.4.13)服务器,该服务器似乎可以在我指定的iPhone模拟器中正确加载我的Sencha Touch应用程序。我可以用Appium检查器检查元素

但是,在编写测试时,我无法识别应用程序初始视图中的任何UI元素。在Sencha Architect中,我已将按钮组件
id
属性设置为
主登录容器新帐户按钮

例如,对于下面的每种情况,似乎从未找到元素。恐怕森查元素的动态生成是我找不到元素的原因。然而,我已经读到Selenium是一个用于Sencha应用程序UI测试的选项,所以它一定很容易实现,对吗?我的项目也用科尔多瓦包装

一,

二,

三,

四,

五,

六,


由于您的应用程序是在Cordova上构建的,因此只需试用,请使用Chrome/Safari上的inspect devices检查元素
主登录容器新帐户按钮
。在您能够访问它之前,您必须在检查时找到一些属性,如
css
class
。 如上所述,如果您能够使用Chrome/Safari检查它们,那么您正在查看一个webview,您必须将其上下文切换到webview才能访问此处的元素

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

注意:如果能看到
Chrome的屏幕截图就好了
应用程序视图中的元素以及与之对应的
Appium Inspector
屏幕截图


如果我使用Chrome或Safari来检查元素,会有区别吗?在Safari for iOS设备中执行此操作要容易得多。我在Safari检查器的父div中看到了Id。我还尝试在驱动程序初始化之后从Mocha调用done(),以确保在before块之后执行测试。当第一个测试的第一行执行时,我确实看到我的应用程序视图在模拟器中呈现。我还尝试过在ElementsByCassName(如普通none类)中搜索无法检索任何元素的位置。然而,当我使用uinormalnone搜索时,我没有得到错误响应,但它最终是一个空数组。我的截图在这里:在你的截图中没有带有
主登录容器新帐户按钮的元素。可能是用科尔多瓦包装的改变了这一点。为了试试运气,您可以在同一个视图上使用XPath访问元素,以了解是否能够访问它们。另请注意:我认为您必须将上下文切换到Webview才能访问此处的元素。
主登录容器“新建帐户”按钮
显示为父div的id。您建议我如何将上下文切换到Webview。这似乎是我唯一的选择,单击并展开以在Inspector中查看我的目标元素。更正:我没有搜索UIAnormal none类,但是调用
UIAnone normal
类。调用
driver.elementsByPath('//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText[5]
似乎可行,但在这里使用xpath标识元素对于编写测试来说似乎不可行。
[...]
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.
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.
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
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
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.
 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!
 [...]