I have a list of WebElements that I check for visibility, but if I don't have one element in page, the check fails, how do I keep checking, but at the same time return false, that there is an error in the method?
public boolean blockElementsIsDisplay() {
List<WebElement> blockElements = new ArrayList<>();
fourBlockElements.add(list1);
fourBlockElements.add(list2);
fourBlockElements.add(list3);
fourBlockElements.add(list1Description);
fourBlockElements.add(list2Description);
fourBlockElements.add(list3Description);
for (WebElement element : blockElements)
if (!element.isDisplayed()) {
System.out.println(element.getAccessibleName() + element.getLocation());
return false;
}
return true;
so if i remove "return false" in code, metod finish with true, but i dont need it I need to check all elements, and return false, if 1 or more is dosent displayed (and write names and locations of this elements)
It was simple -.- Just adding boolean bool; and change return false to bool = false and return true to return bool
public boolean blockElementsIsDisplay() {
boolean bool = true;
List<WebElement> blockElements = new ArrayList<>();
fourBlockElements.add(list1);
fourBlockElements.add(list2);
fourBlockElements.add(list3);
fourBlockElements.add(list1Description);
fourBlockElements.add(list2Description);
fourBlockElements.add(list3Description);
for (WebElement element : blockElements)
if (!element.isDisplayed()) {
System.out.println(element.getAccessibleName() + element.getLocation());
bool = false;
}
return bool;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.