【问题标题】:How to scroll PDF which is inside iframe in selenium java如何在 selenium java 中滚动 iframe 内的 PDF
【发布时间】:2019-04-22 11:44:12
【问题描述】:

这是

下文档位置的标签
<iframe height="900" width="100%" src="/attachments/download/Attachment.pdf" title="document"/>

【问题讨论】:

    标签: java selenium xpath iframe css-selectors


    【解决方案1】:

    内联框架是一种将文档嵌入 HTML 文档的结构,以便嵌入的数据显示在浏览器窗口的子窗口中。这并不意味着完全包含并且两个文档是独立的,并且它们都被视为完整的文档,而不是将一个视为另一个的一部分。

    您可以在Ways to deal with #document under iframe找到详细讨论。

    现在根据最佳实践切换到 iframe,您必须:

    • 诱导 WebDriverWait 使所需的框架可用并切换到它,您可以使用以下任一解决方案:

      • 使用cssSelector

        new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe[src='/attachments/download/Attachment.pdf'][title='document']")));
        
      • 使用xpath

        new WebDriverWait(driver, 10).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[@src='/attachments/download/Attachment.pdf' and @title='document']")));
        

    切换到正确的&lt;iframe&gt; 后,您可以滚动 以及与&lt;iframe&gt; 中的任何元素交互

    【讨论】:

    • 谢谢,但查询是我必须向下滚动没有任何元素与 PDF 交互的 PDF 文档,放置在 :div 标签下的 PDF 请告知如何滚动PDF
    猜你喜欢
    • 2017-11-26
    • 1970-01-01
    • 2014-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-23
    • 2020-09-05
    • 1970-01-01
    相关资源
    最近更新 更多