1

I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.

There is many stuff on the internet and here, but no one works for me.

And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.

I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.

The problem is that I cannot select anything. Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).

If I press ENTER key the confirmation box disappear (so it works fine manually).

This example seems good, but I can't find any interface in Selenium IDE to do this:

driver.switchTo().alert().accept();

(from Click in OK button inside an Alert (Selenium IDE))

I have only the following pattern:

enter image description here

Or write the test in html, which uses the "Command", "Target", "Value" pattern.

Appreciate any help.

EDIT1:

With the link provided by Janesh Kodikara I have found that my problem is:

Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.

There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.

Community
  • 1
  • 1
Andreas L.
  • 2,805
  • 23
  • 23

2 Answers2

1

Once you have a confirmation box, you must consume it (Click OK or Cancel button) You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.

See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.

You will not see the Javascript popup when IDE script is run.

Janesh Kodikara
  • 1,670
  • 1
  • 12
  • 23
  • Thank you for reply Janesh. I see the Javascript popup when script run. Thats the problem. I have testet the example from documentation where it did not appear but on my application it does... I will check your suggestion on monday... – Andreas L. Aug 23 '14 at 17:24
  • Your post is very helpful, but stil not solve my problem. chooseOkOnNextConfirmation does not work for me. I have made an edit my post (EDIT1). With your link I have found the reason of my problem. – Andreas L. Aug 25 '14 at 08:09
-2

Selenium IDE

Command : runScript target : {window.onbeforeunload=function(e){};}

Command :click target : xpath of button.

This will work fine but you are not able to see popup.

Karl
  • 1
  • What xpath does an JavaScript alert button have? – Andreas L. Feb 05 '15 at 12:12
  • Modifying the window.onbeforeload function of an application you are testing doesn't seem to be the best workaround since that might be functionality that is trying to be tested. – NexAddo May 19 '16 at 15:06