How can I get Firebug to match HtmlUnitDriver's pageSource report?

…衆ロ難τιáo~ 提交于 2019-12-12 03:14:21

问题


I'm using Java with the Selenium Library to scrape a webpage. When I use Firebug on the page in Firefox, I can see that the page's source contains the following HTML structure:

<div>
    <div>
        <table>
            <caption />
            <thead />
            <tbody />
        </table>
    </div>
</div>

However, when I programatically download the page's source using HtmlUnitDriver, then use driver.getPageSource(), I see that the corresponding HTML structure has changed to:

<div>
    <table>
        <caption />
        <tbody />
    </table>
</div>
  1. Why does the HtmlUnitDriver's report differ to that given by Firebug?
  2. Can I set up firebug so that I can inspect the HTML structure according to how the HtmlUnitDriver will report it?

回答1:


Note that Firebug does not adjust the HTML structure that way, i.e. the integrated developer tools should show you the same.

I assume the second wrapping <div> and the <thead> get added by some JavaScript running on the page.

You can check that by disabling JavaScript, e.g. by going to about:config and setting javascript.enabled to false or via an add-on like NoScript or Ghostery.



来源:https://stackoverflow.com/questions/39190327/how-can-i-get-firebug-to-match-htmlunitdrivers-pagesource-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!