diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c5baeb9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,18 @@ + +language: perl +perl: + - "5.10" + - "5.12" + - "5.14" + - "5.16" + - "5.18" + - "5.20" + - "5.22" + - "5.24" + +install: + - dzil authordeps --missing | cpanm --no-skip-satisfied + - dzil listdeps --author --missing | cpanm --no-skip-satisfied + +script: + - dzil test --author --release diff --git a/CHANGES b/CHANGES index f16db7e..6519dbd 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +** 0.07 / 2017-05-26 + - Add capacity to check and handle alerts + ** 0.06 / 2016-10-03 - Make 'get_page_source' write info a file diff --git a/dist.ini b/dist.ini index 84134d9..10b4070 100644 --- a/dist.ini +++ b/dist.ini @@ -1,6 +1,6 @@ name = Weasel-Driver-Selenium2 abstract = PHP's Mink inspired multi-protocol web-testing library for Perl -version = 0.05 +version = 0.07 author = Erik Huelsmann copyright_holder = Erik Huelsmann main_module = lib/Weasel/Driver/Selenium2.pm diff --git a/lib/Weasel/Driver/Selenium2.pm b/lib/Weasel/Driver/Selenium2.pm index 430c097..14afdc4 100644 --- a/lib/Weasel/Driver/Selenium2.pm +++ b/lib/Weasel/Driver/Selenium2.pm @@ -5,7 +5,7 @@ Weasel::Driver::Selenium2 - Weasel driver wrapping Selenium::Remote::Driver =head1 VERSION -0.06 +0.07 =head1 SYNOPSIS @@ -47,12 +47,13 @@ use warnings; use MIME::Base64; use Selenium::Remote::Driver; use Time::HiRes; +use Carp qw(croak); use Weasel::DriverRole; use Moose; with 'Weasel::DriverRole'; -our $VERSION = '0.06'; +our $VERSION = '0.07'; =head1 ATTRIBUTES @@ -123,7 +124,7 @@ see L. =cut sub implements { - return '0.02'; + return '0.03'; } =item start @@ -408,6 +409,48 @@ sub set_window_size { $self->_set_window_size($value); } +=item get_alert_text + +Checks if there is a javascript alert/confirm/input on the screen. +Returns alert text if so. + +=cut + +sub get_alert_text { + my ($self) = @_; + my $alertTxt; + + eval { $alertTxt = $self->_driver->get_alert_text() }; + + return $alertTxt; +} + +=item accept_alert + +Accepts the currently displayed alert dialog. Usually, this is +equivalent to clicking the 'OK' button in the dialog. + +=cut + +sub accept_alert { + my ($self) = @_; + $self->_driver->accept_alert; +} + +=item dismiss_alert + +Dismisses the currently displayed alert dialog. For comfirm() +and prompt() dialogs, this is equivalent to clicking the +'Cancel' button. For alert() dialogs, this is equivalent to +clicking the 'OK' button. + +=cut + +sub dismiss_alert { + my ($self) = @_; + $self->_driver->dismiss_alert; +} + =back =cut