Sagar
Sagar

Reputation: 85

Any Way to access elements of PDF opened in a Browser Using Selenium

Actually i am working on automating one web application using Selenium. As we know that the Selenium can only automate web applications only but in my application some of the pages contains PDF document loaded in them, i do need to interact with the buttons in the PDF. Is there any way to do this from Selenium. If possible please do help me out. Thanks in advance.

Upvotes: 0

Views: 2192

Answers (2)

Matthew Wilson
Matthew Wilson

Reputation: 2065

This is an almighty hack, but probably the only way to do it in selenium.

If you use the clickAt method which has two paramaters, the element locator and the coordinates:

void clickAt(java.lang.String locator,
             java.lang.String coordString)

Parameters:
locator - an element locator
coordString - specifies the x,y position (i.e. - 10,20) of the mouse event relative to the element returned by the locator.

If you set the element locator to be the <embed/> object of the PDF, and the coordinates to be the location on the screen of where the buttons on the PDF are. It should click the link in the PDF. However this is very unreliable, but I'm not sure there is a better way to do it.

Upvotes: 0

ddavison
ddavison

Reputation: 29052

It's not possible with Selenium. Selenium automates browsers, not the embedded applications within it.

The extent of what you can do with Selenium as it pertains to PDF's, is validate that the embedded object is there by doing a simple assert that by_id("embeddedPDF") is there

Upvotes: 0

Related Questions