Reputation: 79
I created the code:
new WebDriverWait(driver,100).until(
new ExpectedCondition<Boolean>(){
@Override
public Boolean apply(WebDriver driver){
if(driver.findElement(byLogin).isDisplayed()){
System.out.println("test1");
return true;
}
else if(driver.findElement(byConc).isEnabled()){
System.out.println("test1");
driver.findElement(byShop).click();
return true;
}
return false;
}
}
);
Code after "else if" never executes. How could I make the correct ExpectedCondition having both conditions above?
Upvotes: 4
Views: 2502
Reputation: 16201
You cannot have return
in both if
.else if
blocks if need to satisfy both conditions. Instead have another boolean
variable and return that can be overwritten from both code blocks.
new WebDriverWait(driver,100).until(
new ExpectedCondition<Boolean>(){
boolean ind = false;
@Override
public Boolean apply(WebDriver driver){
if(driver.findElement(byLogin).isDisplayed()){
System.out.println("test1");
ind = true;
}
else if(driver.findElement(byConc).isEnabled()){
System.out.println("test1");
driver.findElement(byShop).click();
ind = true;
}
else{
ind = false;
}
return ind;
}
}
);
Upvotes: 5