Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
201 views
in Selenium by
recategorized by

My below method is not working.

Current test class code:

 WebElement items = driver.findElement(By.className("boxy"));

        List <WebElement> items_list = items.findElements(By.tagName("ul")) ;

        WebElement our_list = items_list.get(0);

        List <WebElement> our_items = our_list.findElements(By.tagName("li"));

 

Current Page objects code:

public static WebElement getListItems (WebDriver driver)

{

WebElement table = driver.findElement(By.className("boxy"));

return table.findElement(By.tagName("ul"));

}

 

public static WebElement getListitem(WebDriver driver)

{

WebElement my_list = greatPlainElements.getListItems(driver).findElement(By.tagName("li"));

return my_list.findElement(By.tagName("li"));

 

}

 

1 Answer

0 like 0 dislike
by
selected by
 
Best answer

Just use:

 

public static List<WebElement> getList(WebDriver driver){
    WebElement items = driver.findElement(By.className("boxy"));
    List <WebElement> items_list = items.findElements(By.tagName("ul")) ;
    WebElement our_list = items_list.get(0);
    return our_list.findElements(By.tagName("li"));
}


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...