5

在使用 protractor.js 为 Angular 2 应用程序编写测试用例时,如果我想让element(by.model("xyz.test"))它总是失败,说 angular 没有定义。

知道如何解决这个问题吗?

4

3 回答 3

8

正如 Protractor 样式指南的贡献者之一 @Carmen Popoviciu 所提到的,by.model 和 by.binding 尚未与 Protractor 和 Angular 2 一起使用:

“请记住,目前并非所有定位器策略都支持 ng2 应用程序。诸如 by.model() 或 by.binding() 之类的东西目前还不起作用。检查 Protractor 更改日志以获取新版本”

https://github.com/CarmenPopoviciu/angular2-go-protractor

于 2016-10-04T20:18:44.980 回答
1

@Gabriel Kohen 的答案绝对准确,但我想我会添加另一个答案,其中包含一些文档链接,这些链接积极阻止使用by.modelby.binding

https://github.com/angular/protractor#compatibility

https://github.com/angular/protractor/blob/master/docs/locators.md#locators

在这一点上,他们可能不太可能得到支持。

于 2018-05-01T14:30:45.710 回答
0

这是一个关于此的 github 问题by.model,在评论中提到。

(这是我目前能找到的唯一一张开放票,如果有人有更好的)

于 2017-06-26T08:12:36.420 回答