Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Selenium HtmlUnitDriver-由于Ajax调用,Gwt源代码未填充_Java_Selenium_Junit - Fatal编程技术网

Java Selenium HtmlUnitDriver-由于Ajax调用,Gwt源代码未填充

Java Selenium HtmlUnitDriver-由于Ajax调用,Gwt源代码未填充,java,selenium,junit,Java,Selenium,Junit,我使用JavaSeleniumHtmlUnitDriver来验证Gwt源代码的html是否由于Ajax调用而未填充。有没有办法执行实际页面并获取页面的源代码?我尝试启用Js,但仍然没有成功。如果您需要处理动态内容,那么最好的机会可能是使用带有JavaScript引擎的浏览器/驱动程序。以下是无头PhantomJS驱动程序的示例: System.setProperty("phantomjs.binary.path", "..."); WebDriver driver = new PhantomJ

我使用JavaSeleniumHtmlUnitDriver来验证Gwt源代码的html是否由于Ajax调用而未填充。有没有办法执行实际页面并获取页面的源代码?我尝试启用Js,但仍然没有成功。

如果您需要处理动态内容,那么最好的机会可能是使用带有JavaScript引擎的浏览器/驱动程序。以下是无头PhantomJS驱动程序的示例:

System.setProperty("phantomjs.binary.path", "...");

WebDriver driver = new PhantomJSDriver();
WebDriverWait wait = new WebDriverWait(driver, 20);

// load the page
driver.get("http://...");

// wait for a dynamic element to be created
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("...")));

// get the page source
String source = driver.getPageSource();

如果您需要处理动态内容,那么最好的方法可能是使用带有JavaScript引擎的浏览器/驱动程序。以下是无头PhantomJS驱动程序的示例:

System.setProperty("phantomjs.binary.path", "...");

WebDriver driver = new PhantomJSDriver();
WebDriverWait wait = new WebDriverWait(driver, 20);

// load the page
driver.get("http://...");

// wait for a dynamic element to be created
wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("...")));

// get the page source
String source = driver.getPageSource();