Reputation: 99
Here, I am getting page content using phantomjsdriver
. I am able to get the complete content of static web pages.
But,I am not able to get complete content of web pages having ajax calls(dynamic web-pages). When I try the below code
I am able to get the content of dynamic web-pages. But I can't predict the loading time of page. So,I am looking for
functions that tells page as been loaded completely.
WebDriver driver = new PhantomJSDriver(caps);
driver.get("http://www.blackwoods.com.au/search/flat-cut-off-wheels-metal-flexovit/302022874");
thread.sleep(10000);
System.out.println(driver.getPageSource());
driver.quit();
Here, I want to use function other then thread.sleep(10000)
;.
Even I tried with below code. But didn't get the complete content
WebDriver driver = new PhantomJSDriver(caps);
driver.get("http://www.blackwoods.com.au/search/flat-cut-off-wheels-metal- flexovit/302022874");
WebDriverWait wait = new WebDriverWait(driver,15);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("ProductsPane")));
System.out.println(driver.getPageSource());
driver.quit();
Upvotes: 0
Views: 1138
Reputation: 328624
Have a look at Web Testing Box and especially look at WaitTool which allows you to easily wait for elements to appear.
The tool for you is waitForJavaScriptCondition()
which allows you to run a piece of JavaScript (in the context of the page under test).
You will then have to look at the framework which is used. If the page uses jQuery, for example, you can use $.active != 0
as condition (see "How do I know if jQuery has an Ajax request pending?").
Upvotes: 1