1

I am doing some non-regression tests with Perl package Selenium::Remote::Driver. I would like to recover a windows Confirm Box . I know i have to execute some Javascript snippet code to recover it. Usually, i can get a web page behaviour not include in Selenium::Remote::Driver package with some Javascript code ( Compare below ) using a selector. But in my case , i can't recover my "Confirm Box" because i can't inspect my "Confrim Box" element. SO i can't use Developer Tools to find a selector or a xpath.

PS: I don't want to know if this alert ("Confirm Box ") exists. I know it's in my web page and i don't want to assert it.

I have to use following Javascript snippet also for example:

   my $script = q{
       var arg1 = arguments[0];
       var elem = window.document.findElementById(arg1);
       return elem;
   };
   my $elem = $driver->execute_script($script,'myid');
   $elem->click;

And below part of code which contains my "Confirm Box" :

if (confirm("Are you sure?")) {
      var promises = [];
      CW.showLoadingPanel();
      $.each(dataGrid.getSelectedRowsData(), function() { ... }
     ...
      };

So how can i do with this issue ?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Chaoui05
  • 288
  • 1
  • 2
  • 11
  • Related: http://stackoverflow.com/a/4934124/1331451 – simbabque Jun 01 '16 at 11:10
  • Possible duplicate of [Selenium + Perl: Check if alert exists?](http://stackoverflow.com/questions/14843724/selenium-perl-check-if-alert-exists) – Mobrockers Jun 01 '16 at 11:37
  • I don't want to assert if my "Alert Box", my "Confirm Box" exists. That's for the first post. And for the second , it doesn't concern Selenium::Remote::Driver . Thanks . – Chaoui05 Jun 01 '16 at 12:19
  • Actually yes, it does use Selenium::remote::Driver.. See "I am using perl with the Selenium::Remote::Driver module to interact with the server." – Mobrockers Jun 01 '16 at 12:32
  • I saw it . Thanks again – Chaoui05 Jun 01 '16 at 14:48

1 Answers1

1

Selenium has some convenience functions to interact with javascript alerts. In perl you can for example accept an alert with the following call:

$driver->accept_alert;

You can get the alert text with the call:

$driver->get_alert_text();

And dismiss the alert using:

$driver->dismiss_alert();
Mobrockers
  • 2,128
  • 1
  • 16
  • 28