2

3个li项目都是不同的。如果所有li内容都相同,则意味着重复,我们必须自动化此场景

我希望代码应该能够自动化查找重复 li 项的过程

$runAction("org.getopentest.selenium.ReadElementText", {
  locator: $data("locators/Profile").ClientsCSP,
  $localData: {
    description: "$output.text"
  }
});
var str1 = $localData.abc;
$log(str1);
<div data-autoid="Clients" class="m-section ItemList__itemList___2dOxf m-body" style="" xpath="1">
  <ul>
    <li data-autoid="Clients_item_0" class="ItemList__label___1N5Nz">1-800 Contacts</li>
    <li data-autoid="Clients_item_1" class="ItemList__label___1N5Nz">10 Advertising</li>
    <li data-autoid="Clients_item_2" class="ItemList__label___1N5Nz">clients_23rd July</li>
  </ul>
</div>

li项目存储在数组中,如果发现重复记录它

4

1 回答 1

1

最好的方法是使用GetElements操作。

- description: Find all li elements
  action: org.getopentest.selenium.GetElements
  args:
    locator: ... # This locator must match all li elements

- script: |
    var listItems = $output.elements;
    var itemsTextArray = listItems.map(function(li) {
          return li.getText();
        })
    // Next, check itemsTextArray for duplicate items
于 2019-10-12T22:49:26.263 回答