-3

Here is the tag of document place under

<iframe height="900" width="100%" src="/attachments/download/Attachment.pdf" title="document"/>
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

An inline frame is a construct which embeds a document into an HTML document so that embedded data is displayed inside a subwindow of the browser's window. This does not mean full inclusion and the two documents are independent, and both them are treated as complete documents, instead of treating one as part of the other.

You can find a detailed discussion in Ways to deal with #document under iframe.

Now as per best practices to switch to an iframe you have to:

  • Induce WebDriverWait for the desired frame to be available and switch to it and you can use either of the following solutions:

    • Using cssSelector:

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

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

Once you switch to the proper <iframe> you can scroll as well as interact with any element within the <iframe>

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks, but query is i have to scroll down PDF document which does not have any element to interact with PDF, the PDF placed under :div tag please advise how to scroll the PDF – Saravanan Seenivasan Nov 20 '18 at 08:44