0

I need to automate click of the OK button (OR press enter key) in the acrobat reader popup which appears in browser after clicking on the button to open pdf file. So it gives you options to open in browser, open in acrobat reader or download. I need to open it in browser and make a screenshot, then switch to parent window (since it opens PDF file in other window).

The problem here is that popup is not part of the web app (not in the DOM), and you can not inspect the element. How do you handle those popups? Please help! Unfortunately I can not attach screenshot of the popup, since its my first question here

////////////////////////////////////////////////// //this is the function which clicks on the button before the popup appears

async viewEligibilityPdf() {
    console.log('******************* ELIGIBILITY RESULTS PAGE ***********');
    await I.waitForText('Eligibility results', 120);

    await I.wait(5);

    await I.waitForEnabled(this.buttons.viewEligibility, 120);
    await I.saveScreenshot(`EligibilityResultsPage.png`);
    await I.click(this.buttons.viewEligibility);

}

2 Answers2

0

The chances are you probably can't. Web browsers have pretty strict security measures that prevent automation especially outside of your own code.

I know that you're unable to post a screenshot, but more information would be helpful.

  • Are you (is your application) generating this PDF?
  • Also, please provide at least a sample of the piece of code where you're opening this PDF.
Thomas Yamakaitis
  • 417
  • 2
  • 6
  • 20
  • Hi @Thomas! Yes, the PDF is created during the flow of the application, and at some point we have a button to click, which opens the acrobat reader popup. Since it can't be inspected I can't click ok, or hit enter (which would solve the problem). I heard about robot class used in java selenium webdriver, which deals with non web applications. So I was wondering if there is anything similar that can be used for javascript, nodejs, codeceptjs. I`ll paste code which clicks on the button before popup, but I don't think it will clarify anything – Sergii Shkvyra Jan 26 '21 at 17:26
  • Sorry for the late response @SergiiShkvyra my next question is, why do you need to click OK? – Thomas Yamakaitis Jan 28 '21 at 14:53
  • The reason I ask is because maybe there's a better way to accomplish what you're trying to do because it would be very difficult to implement what you want for anything besides a personal pet project. Otherwise, you would probably need every user to install something locally to automate the process you want. – Thomas Yamakaitis Jan 28 '21 at 16:24
  • 1
    Posted my solution in answers. Yes, my team will have to install it and as for now looks like there is no other way, it does the job – Sergii Shkvyra Jan 29 '21 at 04:08
0

Found the solution over here. There are drawbacks of it just like Robot class has for example (browser has to be in the foreground one of them), but for now it does the job https://www.npmjs.com/package/node-key-sender