【问题标题】:How to index 2 buttons with same selector in testcafe如何在testcafe中使用相同的选择器索引2个按钮
【发布时间】:2020-08-13 23:38:39
【问题描述】:

我有 2 个带有以下选择器的按钮。如何在 testcafe 自动化中索引它们?

.ng-filter-widget-row > span.ng-filter-widget-column.field-col.form-group.center-block > span > 按钮

【问题讨论】:

  • 索引它们到底是什么意思?
  • 如何逐个访问按钮?
  • 您想通过自动化的 Selector api 访问它们吗?
  • 是这样的。 this.Selector(.ng-filter-widget-row > span.ng-filter-widget-column.field-col.form-group.center-block > span > button); //选择第一个按钮。如何选择具有相同选择器的第二个按钮
  • nth 函数对你有用吗?

标签: javascript java testing automation testcafe


【解决方案1】:

Selector Api 提供了nth 功能,您可以通过索引选择项目。

https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors/functional-style-selectors.html#nth

//first button
Selector(".ng-filter-widget-row > span.ng-filter-widget-column.field-col.form-group.center-block > span > button").nth(1);

// second button
Selector(".ng-filter-widget-row > span.ng-filter-widget-column.field-col.form-group.center-block > span > button").nth(2);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-26
    • 1970-01-01
    • 2014-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    • 1970-01-01
    相关资源
    最近更新 更多