【问题标题】:How to use the locater to find the specifc word with protractor if dont have the id?如果没有 id,如何使用定位器用量角器查找特定单词?
【发布时间】:2021-02-27 20:38:33
【问题描述】:

最近我正在研究如何使用量角器中的定位器进行测试。

但是如果里面没有id怎么定位呢?

例如在我的屏幕截图中,如何在标签中找到“您无权访问此页面,请获取您的”或“访问”字样?

【问题讨论】:

  • 试试by.css('span[ng-bind-html="AccessDenied.HtmlMsg"]')

标签: protractor ui-automation


【解决方案1】:

查看此页面以了解所有可能的定位器策略https://www.protractortest.org/#/api?view=ProtractorBy.prototype.cssContainingText

在您的情况下,cssContainingText 似乎是最合适的,但如果您学习如何使用 id 以外的属性,您也可以使用 xpath 和 css

【讨论】:

    猜你喜欢
    • 2016-01-22
    • 1970-01-01
    • 1970-01-01
    • 2018-09-06
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多