I was trying to automate to select drop down option with set<WebElement> , but while iterating it gives error as NullPointerException . I same tried with List<WebElement> , It works fine.
UserPageObject.java
----------------------------
@FindAll({@FindBy(xpath ="//li[@role='option']/span[@class='ng-star-inserted']")})
private Set<WebElement> DropDownElementStatus;
public Set<WebElement> getDropDownElementStatus() {
return DropDownElementStatus;
}
public void setDropDownElementStatus(Set<WebElement> dropDownElementStatus) {
DropDownElementStatus = dropDownElementStatus;
}
ActionsUtilities.java
---------------------------
public void AllDropDownSetElements(Set<WebElement> dropDownsElements, String DropDownOption ){
Iterator<WebElement> dropDownIteratorElements= dropDownsElements.iterator(); //getting error as NullPointerException on this line
while(dropDownIteratorElements.hasNext())
{
WebElement element= dropDownIteratorElements.next();
if(element.getText().trim().equals(DropDownOption))
element.click();
}
}
UserStepDefifnation.java
-----------------------------
objectList.getActionsUtilities().AllDropDownSetElements(objectList.getUserPageObject().getDropDownElementStatus(),"INACTIVE");