Java 有没有办法得到<;嵌入>;SeleniumWebDriver中的标记资源

Java 有没有办法得到<;嵌入>;SeleniumWebDriver中的标记资源,java,selenium,selenium-webdriver,selenium-chromedriver,Java,Selenium,Selenium Webdriver,Selenium Chromedriver,我正在尝试将pdf嵌入到html文档中。这是参考网站 使用HTML页面上的标记嵌入pdf文档 我有以下几件事- 如果我打开chrome浏览器(我使用的是Version 55.0.2883.87 m),并检查标签上的元素,或者单击F12,然后检查相同的内容,则会显示标签内容,如下所示- <embed src="chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/content/web/viewer.html?file=https%3A%2F

我正在尝试将pdf嵌入到html文档中。这是参考网站

使用
HTML
页面上的
标记嵌入pdf文档

我有以下几件事-

  • 如果我打开chrome浏览器(我使用的是
    Version 55.0.2883.87 m
    ),并检查
    标签上的元素,或者单击
    F12
    ,然后检查相同的内容,则会显示标签内容,如下所示-

    <embed src="chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/content/web/viewer.html?file=https%3A%2F%2Fpdfobject.com%2Fpdf%2Fsample-3pp.pdf#page=2" type="text/html" width="100%" height="100%">
    
    它检索结果为-

    <embed width="100%" height="100%" name="plugin" id="plugin" src="https://pdfobject.com/pdf/sample-3pp.pdf#page=2" type="application/pdf" internalinstanceid="9">
    
    相同的快照是相同的-

    我这里有几个问题-

  • 使用安装的系统
    chrome
    chromedriver.exe
    打开的
    chrome
    检查元件的变化

  • 有没有办法得到chromedriver打开的结果

  • 有没有办法让
    嵌入
    html

  • 如果手动运行Chrome,您似乎已经安装了PDF渲染器。但是,如果Chrome是由chromedriver启动的,它运行时没有任何浏览器扩展,这就是为什么在这种情况下,您会得到Chrome的默认行为(即自行呈现PDF)

    如果您确实需要验证PDF是否使用该特定扩展加载和呈现,那么当chromedriver启动Chrome时,您也可以使用以下方法加载扩展(代码取自):


    有关如何获取扩展名的crx文件,请参见此处:

    谢谢回复。你说得对,我的系统中安装了“PDF查看器Chrome extension”。禁用后,它将显示与通过
    chromedriver
    打开的chrome相同的
    行为。我是否按预期获得
    标记的默认呈现内容。在新打开的开发工具控制台中出现?
    <embed width="100%" height="100%" name="plugin" id="plugin" src="https://pdfobject.com/pdf/sample-3pp.pdf#page=2" type="application/pdf" internalinstanceid="9">
    
    <embed id="plugin" type="application/x-google-chrome-pdf" src="https://pdfobject.com/pdf/sample-3pp.pdf#page=2" stream-url="blob:chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/e8337a7a-5af1-456c-8f7a-d8132c67fe6d" headers="Accept-Ranges: bytes
    Cache-Control: max-age=2592000
    Content-Length: 49672
    Content-Type: application/pdf
    Date: Wed, 25 Jan 2017 04:51:36 GMT
    Expires: Fri, 24 Feb 2017 04:51:36 GMT
    Last-Modified: Sat, 19 Mar 2016 06:18:44 GMT
    MS-Author-Via: DAV
    Server: Apache
    X-Content-Type-Options: nosniff
    " background-color="0xFF525659" top-toolbar-height="56" top-level-url="https://pdfobject.com/static.html">
    
    ChromeOptions options = new ChromeOptions();
    options.addExtensions(new File("/path/to/extension.crx"));
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    ChromeDriver driver = new ChromeDriver(capabilities);