Я пытаюсь использовать HtmlUnit, чтобы проверить, что мой сайт GWT загружен правильно.HtmlUnit with GWT возвращает неполную страницу
К сожалению, страница, которую я получаю, не кажется полной. Отсутствует контент, который можно просмотреть, когда я посещаю страницу в своем обычном браузере.
Вот мой блок тест, который производит этот выход:
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnScriptError(false);
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
webClient.waitForBackgroundJavaScript(30000);
HtmlPage page = webClient.getPage("http://www.ozdroid.com/#!BLOG/2010/10/12/How_to_Make_Google_AppEngine_Applications_Ajax_Crawlable");
System.out.println(page.asXml());
webClient.closeAllWindows();
Кто-нибудь есть идея, что я могу сделать, чтобы обойти эту проблему и получать полную Html сайта?
Редактировать
Вот то, что page.asXml()
возвращается с обновленным кодом, который является явно неполным:
<?xml version="1.0" encoding="ISO-8859-1"?>
<html xmlns:fb="http://www.facebook.com/2008/fbml>
<head>
<meta http-equiv=" content-type="">
<head>
<meta name="google-site-verification" content="_KCG8ec0LvgmXjnBAikAog0knc7jAbIGCu8Cmu2hsCI"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
<link rel="shortcut icon" href="favicon.ico"/>
<link rel="icon" type="image/gif" href="favicon.gif"/>
<title>
OzDroid - Enterprise Solutions for Android | Laser Barcode
scanners | RFID | Handheld Computers | Rugged PDA's and Mobile Phones
</title>
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
//]]>
</script>
<script type="text/javascript" language="javascript" src="ozdroid/ozdroid.nocache.js">
</script>
<script defer="defer">
//<![CDATA[
ozdroid.onInjectionDone('ozdroid')
//]]>
</script>
<script src="http://www.google-analytics.com/ga.js" type="text/javascript">
</script>
</head>
<body>
<!-- OPTIONAL: include this if you want history support --> <iframe src="javascript:''" id="__gwt_historyFrame" style="position: absolute; width: 0; height: 0; border: 0">
</iframe>
<noscript>
<div
style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
<p>Welcome, to the website of OzDroid, we sell and distribute rugged Android
handheld computers, pda's and mobile phones. These devices can be equipped
with options including 1D and 2D laser barcode scanners, RFID, wifi,
bluetooth and cameras.</p>
<p> In the near future, we also
will be supplying logistics software for the same.
</p>
<p>As this site contains dynamic content that relies on javascript,
<b>your web browser must have JavaScript enabled</b> in order for this site to
display correctly.
</p></div>
</noscript>
<div id="fb-root">
</div>
<!-- Production --> <script src="http://connect.facebook.net/en_GB/all.js">
</script>
</body>
</html>
Благодаря
GWT приложения богатые приложения Javascript, а не только статические веб-страницы. Разметка HTML не будет содержать источник всего, что вы видите при загрузке страницы в браузере - большая часть из них загружается javascript. –
Возможно, это ошибка htmlunit, почему бы вам не спросить? – milan
@NickJohnson Я использую HtmlUnit для точной цели просмотра полностью отображаемой страницы. – Cuga