0

How can I select the on of element, and this element contains a collection of elements, How can I select or pass through this element's collection?

  • the default search method WebDriverRunner.getWebDriver().findElements(By.tagName("*")); is $$("*") they consider that default space to search is the whole document, how can I specify the region to search? Assume that I need the a tags from the region or from specific element.

I have the following schema for my page:

  <div class="class1"> 
     <a href=""  />
     <a href=""  />
     <img src="img.png" /> 
  </div>
  <a href=""  />
  <a href=""  />
  <div class="class2"> 
     <a href=""  />
     <div class="class4"> <div>
   </div>

How can I pass all elements of div class="class1", ex: after select div.class1 element, I need to see all elements inside this div.

Hana90
  • 943
  • 5
  • 17
  • 37

1 Answers1

1

You should find first div class="class1" then using this object find all element under this like below code:

WebElement el = WebDriverRunner.getWebDriver().findElement(By.className("class1"));
List<WebElement> elements =  el.findElements(By.tagName("*"));

Let me know if this will not work!!!

Thanks Sadik

Sadik Ali
  • 1,129
  • 10
  • 26