| 1 | package Alien::SeleniumRC; | ||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 1 | our $VERSION = '3.7'; | |||||||||||
| 6 | 1 | our $SELENIUM_SERVER_VERSION = '3.141.59'; # Reminder: Update version in doc below | |||||||||||
| 7 | 1 | our $VERBOSE = 1; | |||||||||||
| 8 | |||||||||||||
| 9 | 1 | ▶ | use 5.006; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 3 | ▶ | sub start { | ||||||||||
|
Subroutine
start: called CC=6 SCAR=19.0
Pod
documented
| |||||||||||||
| 12 | 3 | ▶ | my $args = shift || ''; | ||||||||||
|
Condition100%2/2
shift() || ''
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||
| 13 | 3 | my $jarfile = find_jar_location(); | |||||||||||
| 14 | |||||||||||||
| 15 | 3 | my $cmd = "java -jar $jarfile $args"; | |||||||||||
| 16 | 3 | ▶ | if ( $ENV{SELENIUMRC_USE_SIC} ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 0 | $cmd = "sudo /usr/libexec/StartupItemContext `which java` -jar $jarfile $args"; | |||||||||||
| 18 | } | ||||||||||||
| 19 | |||||||||||||
| 20 | 3 | ▶ | print "Running $cmd\n" if $VERBOSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 21 | 3 | my $ret = system($cmd); | |||||||||||
| 22 | 3 | ▶ | die "Failed to run '$cmd': $!" if $ret == -1; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | 3 | ▶ | print "Selenium server has finished\n" if $VERBOSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 24 | } | ||||||||||||
| 25 | |||||||||||||
| 26 | 1 | ▶ | sub help { | ||||||||||
|
Subroutine
help: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 27 | # ignore the return code of selenium-server.jar -help | ||||||||||||
| 28 | 1 | start('-help'); | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 4 | ▶ | sub find_jar_location { | ||||||||||
|
Subroutine
find_jar_location: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||
| 32 | 4 | my $pm_location = $INC{'Alien/SeleniumRC.pm'}; | |||||||||||
| 33 | 4 | (my $src_location = $pm_location) =~ s#\.pm#/selenium-server.jar#; | |||||||||||
| 34 | |||||||||||||
| 35 | 4 | ▶ | if ($^O eq 'cygwin') { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 36 | 0 | $src_location = `cygpath -m '$src_location'`; | |||||||||||
| 37 | 0 | chomp $src_location; | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 4 | ▶ | die "Can't find $src_location!" unless -e $src_location; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 41 | 4 | return $src_location; | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 1 | 1; | |||||||||||
| 45 | |||||||||||||
| 46 | =head1 NAME | ||||||||||||
| 47 | |||||||||||||
| 48 | Alien::SeleniumRC - Packages the Selenium Remote Control server. | ||||||||||||
| 49 | |||||||||||||
| 50 | =head1 SYNOPSIS | ||||||||||||
| 51 | |||||||||||||
| 52 | use Alien::SeleniumRC; | ||||||||||||
| 53 | Alien::SeleniumRC::start(); | ||||||||||||
| 54 | |||||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||||
| 56 | |||||||||||||
| 57 | The Selenium Server (formerly known as Selenium RC Server) is at | ||||||||||||
| 58 | L<http://seleniumhq.org/download/> | ||||||||||||
| 59 | |||||||||||||
| 60 | Selenium Server is a test tool that allows you to write automated web | ||||||||||||
| 61 | application UI tests in any programming language against any HTTP | ||||||||||||
| 62 | website using any mainstream JavaScript-enabled browser. | ||||||||||||
| 63 | |||||||||||||
| 64 | The Selenium Server is needed in order to run either Selenium RC style | ||||||||||||
| 65 | scripts or Remote Selenium Webdriver ones. The 2.x server is a drop-in | ||||||||||||
| 66 | replacement for the old Selenium RC server and is designed to be | ||||||||||||
| 67 | backwards compatible with your existing infrastructure. | ||||||||||||
| 68 | |||||||||||||
| 69 | Selenium Server can automatically start/stop/control any supported | ||||||||||||
| 70 | browser. It works by using Selenium Core, a pure-HTML+JS library that | ||||||||||||
| 71 | performs automated tasks in JavaScript. | ||||||||||||
| 72 | |||||||||||||
| 73 | =head1 METHODS | ||||||||||||
| 74 | |||||||||||||
| 75 | =head2 C<start> | ||||||||||||
| 76 | |||||||||||||
| 77 | This method launches the Selenium Server bundled in this package. | ||||||||||||
| 78 | This call will block until the server is killed. The method will throw | ||||||||||||
| 79 | an exception with C<die> if the C<system> call returns an error. | ||||||||||||
| 80 | |||||||||||||
| 81 | The first argument passed to start() will be passed to | ||||||||||||
| 82 | selenium-server.jar as a command line argument. | ||||||||||||
| 83 | |||||||||||||
| 84 | =head2 C<help> | ||||||||||||
| 85 | |||||||||||||
| 86 | Prints the selenium-server.jar usage. | ||||||||||||
| 87 | |||||||||||||
| 88 | =head1 UPDATING SELENIUM-SERVER.JAR | ||||||||||||
| 89 | |||||||||||||
| 90 | A copy of C<selenium-server.jar> is installed in the C<Alien::SeleniumRC> | ||||||||||||
| 91 | module directory. The Selenium RC version in this distribution is | ||||||||||||
| 92 | B<Version 3.141.59>, released 2018-11-14. | ||||||||||||
| 93 | |||||||||||||
| 94 | To update your local copy, download SeleniumRC from L<http://seleniumhq.org/download/> | ||||||||||||
| 95 | and extract the file C<selenium-server.jar>. Copy it to the Alien::SeleniumRC | ||||||||||||
| 96 | module directory. On most systems, you can find that path by typing | ||||||||||||
| 97 | |||||||||||||
| 98 | perldoc -l Alien::SeleniumRC | ||||||||||||
| 99 | |||||||||||||
| 100 | =head1 ENVIRONMENT VARIABLES | ||||||||||||
| 101 | |||||||||||||
| 102 | Previous versions of L<Alien::SeleniumRC> used C<sudo> to launch the | ||||||||||||
| 103 | Java process using C<StartupItemContext> when running under any | ||||||||||||
| 104 | version of Mac OSX. Running C<sudo> in the middle of automated test | ||||||||||||
| 105 | suites can be problematic and not always required so from 1.01 on this | ||||||||||||
| 106 | is no longer the default behaviour. | ||||||||||||
| 107 | |||||||||||||
| 108 | To get the old behaviour back, set the environment variable | ||||||||||||
| 109 | C<SELENIUMRC_USE_SIC> to a true value before calling C<start>. | ||||||||||||
| 110 | |||||||||||||
| 111 | =head1 SEE ALSO | ||||||||||||
| 112 | |||||||||||||
| 113 | L<WWW::Selenium>, L<Test::WWW::Selenium> | ||||||||||||
| 114 | |||||||||||||
| 115 | Selenium Server home page: L<http://seleniumhq.org/projects/remote-control/> | ||||||||||||
| 116 | |||||||||||||
| 117 | Selenium home page: L<http://seleniumhq.org/> | ||||||||||||
| 118 | |||||||||||||
| 119 | =head1 LICENSE | ||||||||||||
| 120 | |||||||||||||
| 121 | This software is released under the same terms as perl itself. | ||||||||||||
| 122 | If you don't know what that means visit http://perl.com/ | ||||||||||||
| 123 | |||||||||||||
| 124 | Copyright 2006 by Luke Closs | ||||||||||||
| 125 | |||||||||||||
| 126 | All rights Reserved | ||||||||||||
| 127 | |||||||||||||
| 128 | =head1 AUTHOR | ||||||||||||
| 129 | |||||||||||||
| 130 | Luke Closs <selenium-rc@awesnob.com> | ||||||||||||
| 131 | |||||||||||||
| 132 | Cygwin support provided by: Kevin Jones <kevin_jones@telus.net> | ||||||||||||
| 133 | |||||||||||||
| 134 | Co-maintainer Daniel Austin <hisso@cpan.org> | ||||||||||||
| 135 | |||||||||||||
| 136 | =cut | ||||||||||||