In my application when i opens a page a dropdown displays and then i need to click on a proceed button. Problem is drop down takes some time to load the values but in my code it click before the drop down loads.I tried with implicit wait and thread.sleep but it some time it work and some time doesn't work. Code:
public class Home {
public static void main(String[] args) throws IOException, InterruptedException
{
File file1 = new File("C:\\Selenium\\IEDriverServer_Win32_2.35.3\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file1.getAbsolutePath());
WebDriver driver = new InternetExplorerDriver();
driver.get("http://10.120.13.100/");
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
Thread.sleep(3000);
WebElement clickBtn = driver.findElement(By.id("btnHomeProceed"));
clickBtn.click();
You can use FluentWait
final Select droplist = new Select(driver.findElement(By.Id("selection")));
new FluentWait<WebDriver>(driver)
.withTimeout(60, TimeUnit.SECONDS)
.pollingEvery(10, TimeUnit.MILLISECONDS)
.until(new Predicate<WebDriver>() {
public boolean apply(WebDriver d) {
return (!droplist.getOptions().isEmpty());
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With