Reputation: 1087
Im trying to create a script which tests https://www.mail.com/int/ but the website seems to take ages to load (The load bard 'circle' never seems to stop), I have added page load timeouts, but it seems to be taking longer than expected to load, any ideas?
Upvotes: 0
Views: 840
Reputation: 1234
Use an explicit wait until the element(s) that you want to test load.
You didn't specify a language, so I assumed C#.
using (IWebDriver driver = new ChromeDriver())
{
driver.Url = "https://www.mail.com/int/";
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IWebElement myDynamicElement = wait.Until<IWebElement>(d => d.FindElement(By.Id("someDynamicElement")));
}
Upvotes: 0
Reputation: 2091
Yes, indeed it is slow. When inspecting in the Developer Tools > Network, it takes ~30 secs to load due to GIFs and other data heavy requests.
You should use WebDriverWait
to handle such cases:
WebDriverWait wait = new WebDriverWait(driver, 30);
boolean pageLoaded = wait.until(ExpectedConditions.jsReturnsValue("return document.readyState")).equals("complete");
System.out.println("Page has loaded? " + pageLoaded);
The above seemed to work for me. Try it and let me know.
Upvotes: 1