Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
How to re-write page objects when test class involves some navigation

Solved 1 Answers 113 Views Selenium
0 1

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
Best answer
0

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"));
}

answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...