I've written a script using Selenium with Java. It is working fine sometimes without any kind of exceptions. But sometimes I'm getting TimeOutException as I've used explicit wait. Does this kind of behavior relate to the application? What could be the problem?
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
WebDriver driver = new ChromeDriver(options);
driver.get("url");
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.id("usernameid")));
driver.findElement(By.id("usernameid")).sendKeys("632145");
wait.until(ExpectedConditions.elementToBeClickable(By.id("passwordid")));
driver.findElement(By.id("passwordid")).sendKeys("1234");
wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//button[@type='button']")));
driver.findElement(By.xpath(".//button[@type='button']")).click();
The script is failing sometimes at the button. I'm getting TimeOutException.