在 Angular 个站点上使用 Protractor 的替代方法
Alternative to using Protractor on Angular sites
我正在测试一个 Angular 站点。我一直在 Java 中使用 Webdriver,但我无法识别页面上具有正常 ID、xpath 或 类 的元素。
我做了额外的研究,看起来我可能被迫走 Java脚本路线。我研究了 Protractor 和 Jasmine,但我不喜欢 Jasmine 语法。
是否有替代解决方案可以在不使用 Protractor/Jasmine 的情况下测试 Angular 站点?我不 对 Cucumber 或 Mocha 或任何类似于该语法或那些框架的解决方案感兴趣。
如果我能以某种方式使用 Java 那就太好了。我是 Selenium Webdriver 的忠实粉丝,并且更喜欢使用该工具的任何解决方案。附带一提,我研究了 NodeJS 和 WebdriverJS,它们看起来相当脆弱,但我目前正在研究它。
欢迎任何意见。
使 Protractor
成为 AngularJS 端到端测试自动化的完美选择的原因在于,它是专门为测试 AngularJS 应用而制作和设计的 - 它适用于与 Angular 同步,知道 Angular 何时准备好进行交互,消除所有不必要的延迟和等待,您可能已经添加以等待页面加载或显示特定元素:
You no longer need to add waits and sleeps to your test. Protractor
can automatically execute the next step in your test the moment the
webpage finishes pending tasks, so you don’t have to worry about
waiting for your test and webpage to sync.
还有 AngularJS 特定的定位器,如 by.binding
、by.model
、by.repeater
等
此外,还有高级函数式编程功能 - map()
、filter()
、each()
等
还有更多其他功能。
了解 Protractor
只是 WebDriverJS
- javascript selenium 绑定的方便包装器也很重要。
当然,您可以使用裸 java
selenium 绑定来测试 Angular 应用程序,但是您必须自己手动处理所有等待,这至少会使您的测试代码库更加复杂且可读性差。测试流程不会像 Protractor
.
那样自然
此外,还有类似Protractor
其他语言的包:
pytractor
(Python)
protractor-net
(C#)
我们正在使用 Selenium Webdriver / Java 为 Angular JS 网络应用程序开发测试脚本。 我能理解您对 Jasmine 语法的厌恶。
The procedure we are following is to have a standard set for attribute
Ids attached to the web components using which we are able to identify
the element. (By.id) (For this you will need support of Development team)
Other than that , even when element ids are not available and web
components contain attributes like ng-bind , ng-model etc.,I have been
successful in identifying elements using xpath.
能否请您提供一些您无法使用 xpath 识别的详细信息html。
我们正在使用机器人框架来测试 angular JS 应用程序,与量角器相比,它运行良好并且具有非常好的报告工具。是关键字驱动的框架,比较难学,大家可以试试看。
我正在测试一个 Angular 站点。我一直在 Java 中使用 Webdriver,但我无法识别页面上具有正常 ID、xpath 或 类 的元素。
我做了额外的研究,看起来我可能被迫走 Java脚本路线。我研究了 Protractor 和 Jasmine,但我不喜欢 Jasmine 语法。
是否有替代解决方案可以在不使用 Protractor/Jasmine 的情况下测试 Angular 站点?我不 对 Cucumber 或 Mocha 或任何类似于该语法或那些框架的解决方案感兴趣。
如果我能以某种方式使用 Java 那就太好了。我是 Selenium Webdriver 的忠实粉丝,并且更喜欢使用该工具的任何解决方案。附带一提,我研究了 NodeJS 和 WebdriverJS,它们看起来相当脆弱,但我目前正在研究它。
欢迎任何意见。
使 Protractor
成为 AngularJS 端到端测试自动化的完美选择的原因在于,它是专门为测试 AngularJS 应用而制作和设计的 - 它适用于与 Angular 同步,知道 Angular 何时准备好进行交互,消除所有不必要的延迟和等待,您可能已经添加以等待页面加载或显示特定元素:
You no longer need to add waits and sleeps to your test. Protractor can automatically execute the next step in your test the moment the webpage finishes pending tasks, so you don’t have to worry about waiting for your test and webpage to sync.
还有 AngularJS 特定的定位器,如 by.binding
、by.model
、by.repeater
等
此外,还有高级函数式编程功能 - map()
、filter()
、each()
等
还有更多其他功能。
了解 Protractor
只是 WebDriverJS
- javascript selenium 绑定的方便包装器也很重要。
当然,您可以使用裸 java
selenium 绑定来测试 Angular 应用程序,但是您必须自己手动处理所有等待,这至少会使您的测试代码库更加复杂且可读性差。测试流程不会像 Protractor
.
此外,还有类似Protractor
其他语言的包:
pytractor
(Python)protractor-net
(C#)
我们正在使用 Selenium Webdriver / Java 为 Angular JS 网络应用程序开发测试脚本。 我能理解您对 Jasmine 语法的厌恶。
The procedure we are following is to have a standard set for attribute Ids attached to the web components using which we are able to identify the element. (By.id) (For this you will need support of Development team)
Other than that , even when element ids are not available and web components contain attributes like ng-bind , ng-model etc.,I have been successful in identifying elements using xpath.
能否请您提供一些您无法使用 xpath 识别的详细信息html。
我们正在使用机器人框架来测试 angular JS 应用程序,与量角器相比,它运行良好并且具有非常好的报告工具。是关键字驱动的框架,比较难学,大家可以试试看。