0

I am building a UI testing framework which uses a headless browser (phantomJS in my case) to interact with html documents - without using jQuery I need to display a prompt (which is fine) and then programmatically enter text into the prompt dialog and then click OK, all with pure javascript. This will then add some text to a div so that I can verify the result.

Everything I have read online seems to suggest that this is not possible as the prompt/dialog boxes are built-in to the browser itself and not part of the DOM. I cannot see any properties/methods on the DOM to get the dialog and document.activeElement is returning me back the page, not the prompt. So I'm stumped.

How do I do this?

thisextendsthat
  • 1,266
  • 1
  • 9
  • 26

2 Answers2

0

Alert & prompt are not part of DOM, they are part of browser. You can't simulate their invoke behavior from your code.

Gurdev Singh
  • 1,996
  • 13
  • 11
0

I think you need an external program (i.e. a program that runs besides the browser) which can detect prompt windows from the browser, and then fill them with text and submit them. I suggest you start with programs that can simulate key strokes like this user asked.

Community
  • 1
  • 1
andreini
  • 188
  • 1
  • 3
  • 17