I am currently doing an internship at a company, and I have to test an app that reacts differently each time. I run my test case, it passes, and 5 minutes later, I run it again, and it fails. What frustrates me is why the compiler cannot find or interact with the element sometimes. Additionally, there are some input boxes where I was unable to use sendKeys, and I had to combine it with JavascriptExecutor and explicit waits.
While trying to find a more compatible solution that I can use for most input boxes, I found this line of code:
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("loader")));
It works for almost all situations, but this time, although WebDriverWait is set to a maximum of 2 seconds, my test cases run very slowly. One simple test case takes around 2 minutes.
Can someone please explain why this line takes too long to execute, and are there any better alternatives?