I am trying to validate a scenario where I want to click an element only if the element is loaded, but the problem is that both these elements are on a different panel. Below is the piece of code:
@FindBy(xpath = "//div[contains(@class,'PriceButton')]")
List<WebElement> priceButton;
The method to load the above element:
public List<WebElement> loadList() {
return priceButtonList;
}
Element to locate PhotoButton
@FindBy(xpath = "//div[contains(@class,'PhotoButton')]")
List<WebElement> photoButton;
Method to verify photo button present
public void verifyPhotoButton() {
photoButton.verifyPresent();
}
Then in the Page class I have implemented the above method
public void clickOptionThatHasAPhoto() {
for(WebElement list : loadList()) {
if(verifyPhotoButton()) {
priceButton.click();
break;
}
}
I need to know how I can use if condition with verify method.
Aucun commentaire:
Enregistrer un commentaire