简体   繁体   English

在为Cordova iOS应用构建Appium测试框架的同时,找到选择器的任何简便方法

[英]Any easier way for finding selectors, while building Appium test framework for Cordova iOS app

I am working on automating a iOS app using Appium-Java. 我正在使用Appium-Java自动化iOS应用程序。

While writing the Page objects we need to find identifiers ( driver.findelement ) or when UI changes. 在编写Page对象时,我们需要查找标识符( driver.findelement )或UI更改时。

Currently its tedious job, as manually need to traverse through till required screen & then write the selectors( n CSS / XPath / XCUnit based Xpath) 当前它的工作很繁琐,因为需要手动遍历直到需要的屏幕,然后编写选择器(基于CSS / XPath / XCUnit的Xpath)

  1. Currently, there's no easy way to test CSS selectors / XPath (unlike web where we can test it then & there on Firefox / chrome using browser add-ons) 当前,尚没有简便的方法来测试CSS选择器/ XPath(与网络不同,我们可以使用浏览器插件在Firefox / chrome上进行测试)

  2. Is there any way to invoke certain screen directly instead of traversing from the starting point in iOS/Android native app or Cordova based app, while writing the selectors? 在编写选择器时,有什么方法可以直接调用某些屏幕,而不是从iOS / Android本机应用程序或基于Cordova的应用程序中的起点开始遍历?

Kindly advise. 好心提醒。 Thanks. 谢谢。

For a Cordova-based iOS app, you can use wd and wd-bridge to provide a mechanism to allow Appium to communicate directly with the Webview, enabling you to use CSS selectors. 对于基于Cordova的iOS应用,您可以使用wdwd-bridge提供一种机制,以允许Appium直接与Webview通信,从而使您能够使用CSS选择器。

This blog post gives a great tutorial on how to setup such a test environment using Protractor/Jasmine. 这篇博客文章提供了很棒的教程,介绍如何使用Protractor / Jasmine设置这样的测试环境。

You can then write Protractor tests which allow you to reference your app UI elements as HTML components, eg: 然后,您可以编写量角器测试,使您可以将应用程序UI元素引用为HTML组件,例如:

describe('Testing the app', function () {
  it('01. should have a header', function () {
    var header = element(by.id('header'));
    expect(header.getAttribute('class')).toContain('toolbar');
   });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM