Can this be simplified?
How would you simplify this code snippet?
wait.until(ExpectedConditions.elementToBeClickable(by));
WebElement element = driver.findElement(by);
Select list = new Select(element);
list.selectByVisibleText(element);How about like this?
WebElement element = wait.until(elementToBeClickable(by));
Select list = new Select(element);
list.selectByVisibleText(element);What are the improvements?
There is no need to use the ExpectedConditions class name.
elementToBeClickable() is a static method of ExpectedConditions.
Adding this static import to the class allows not using the ExpectedConditions:
import static org.openqa.selenium.support.ui.ExpectedConditions.*;There is no need to find the element using driver.findElement()
wait.until(ExpectedConditions.elementToBeClickable()) returns the web element if the element is in the page and is clickable.
