0

How can I add to the list with CSS selector or something work. First of all, I tried this code below.

List<WebElement> categories = driver.findElements(By.xpath("//div[@class=ui-select-choices-row-inner]/span"))
System.out.println(categories.size());

And I've got a div class like this

<div class="ui-select-choices-row-inner" uis-transclude-append>
<span ng-bind-html="category.name I highlight: $select.search">Test Pre pro</span>

I need this list to make a loop into my automatic test.

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
  • Plz be more specific for what you want to do? What "list to make a loop in my automatic test" suppose to mean? – YourHelper Nov 18 '20 at 20:56

1 Answers1

0

To create a List and you can use either of the following Locator Strategies:

  • cssSelector:

    List<WebElement> categories = driver.findElements(By.cssSelector("div.ui-select-choices-row-inner[uis-transclude-append] > span[ng-bind-html]"))
    System.out.println(categories.size());
    
  • xpath:

    List<WebElement> categories = driver.findElements(By.xpath("//div[@class='ui-select-choices-row-inner' and @uis-transclude-append]/span[@ng-bind-html]"))
    System.out.println(categories.size());
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217