Reputation: 1
My question is.. when we hit any URL of a web page in the browser, the page starts loading. At top we get loading symbol , once it is stopped our selenium script proceed with further process. BUT sometimes the page takes time to load all its properties. is thr any way to wait till the page gets completely loaded with all properties.
Method different than WebDriverWait needed.
Upvotes: 0
Views: 609
Reputation: 2776
You can use a page load timeout to define how much time is needed for page loading.
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
Or else if the page contains some ajax components which are loading behind the scene you can wait for such element to be visible before executing the rest of the steps.
WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.visibilityOfElementLocated(By.id("myDynamicElement")));
In the above code snippet we are defining a wait until a dynamic web element is visible in the webpages.
Documentation on webdriver conditions can be found here
Upvotes: 1