2

3 li items all are different. If all li are the same it means duplicate and we have to automate this scenario

I expect that code should able to automate the process of finding duplicate li items

$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>

store li items in the array and if duplicate found log it

Adrian Theodorescu
  • 11,664
  • 2
  • 23
  • 30

1 Answers1

1

The best way to go about it is to use the GetElements action.

- 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
Adrian Theodorescu
  • 11,664
  • 2
  • 23
  • 30