Perl Bindings to the Selenium Webdriver server
Perl Perl6 HTML JavaScript Shell
Latest commit a873fa1 Aug 25, 2016 @gempesaw committed on GitHub Merge pull request #276 from gempesaw/simplify-mock-recordings
Simplify mock recordings

Selenium::Remote::Driver Build Status

Selenium WebDriver is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser. This module is a Perl implementation of the client for the Webdriver JSONWireProtocol that Selenium provides.


It's probably easiest to use the cpanm or CPAN commands:

$ cpanm Selenium::Remote::Driver

If you want to install from this repository, see the installation docs for more details.


You can use this module to directly start the webdriver servers, after downloading the appropriate ones and putting the servers in your $PATH. This method does not require the JRE/JDK to be installed, nor does it require the standalone server jar, despite the name of the module. In this case, you'll want to use the appropriate class for driver construction: either Selenium::Chrome, Selenium::Firefox, Selenium::PhantomJS, or Selenium::InternetExplorer.

You can also use this module with the selenium-standalone-server.jar to let it handle browser start up for you, and also manage Remote connections where the server jar is not running on the same machine as your test script is executing. The main class for this method is Selenium::Remote::Driver.

Regardless of which method you use to construct your browser object, all of the classes use the functions listed in the S::R::Driver POD documentation, so interacting with the browser, the page, and its elements would be the same.

no standalone server

  • Firefox 48 & newer: install the Firefox browser, download geckodriver and put it in your $PATH. If the Firefox browser binary is not in the default place for your OS and we cannot locate it via which, you may have to specify the binary location during startup.

  • Firefox 47 & older: install the Firefox browser in the default place for your OS. If the Firefox browser binary is not in the default place for your OS, you may have to specify the binary location during startup.

  • Chrome: install the Chrome browser, download Chromedriver and get chromedriver in your $PATH.

  • PhantomJS: install the PhantomJS binary and get phantomjs in your $PATH. The driver for PhantomJS, Ghostdriver, is bundled with PhantomJS.

When the browser(s) are installed and you have the appropriate binary in your path, you should be able to do the following:

my $firefox = Selenium::Firefox->new;

my $chrome = Selenium::Chrome->new;

my $ghost = Selenium::PhantomJS->new;

Note that you can also pass a binary argument to any of the above classes to manually specify what binary to start. Note that this binary refers to the driver server, not the browser executable.

my $chrome = Selenium::Chrome->new(binary => '~/Downloads/chromedriver');

See the pod for the different modules for more details.

with a standalone server

Download the standalone server and have it running on port 4444:

$ java -jar selenium-server-standalone-X.XX.X.jar

As before, have the browsers themselves installed on your machine, and download the appropriate binary server, passing its location to the server jar during startup.


use strict;
use warnings;
use Selenium::Remote::Driver;

my $driver = Selenium::Remote::Driver->new;
print $driver->get_title . "\n"; # "Google"

my $query = $driver->find_element('q', 'name');
$query->send_keys('CPAN Selenium Remote Driver');

my $send_search = $driver->find_element('btnG', 'name');

# make the find_element blocking for a second to allow the title to change
my $results = $driver->find_element('search', 'id');

print $driver->get_title . "\n"; # CPAN Selenium Remote Driver - Google Search


If using Saucelabs, there's no need to have the standalone server running on a local port, since Saucelabs provides it.

use Selenium::Remote::Driver;

my $user = $ENV{SAUCE_USERNAME};

my $driver = Selenium::Remote::Driver->new(
    remote_server_addr => $user . ':' . $key . '',
    port => 80

print $driver->get_title();

There are additional usage examples on metacpan, and also in this project's wiki, including setting up the standalone server, running tests on Internet Explorer, Chrome, PhantomJS, and other useful example snippets.

Selenium IDE Plugin

ide-plugin.js is a Selenium IDE Plugin which allows you to export tests recorded in Selenium IDE to a perl script.

Installation in Selenium IDE

  1. Open Selenium IDE
  2. Options >> Options
  3. Formats Tab
  4. Click Add at the bottom
  5. In the name field call it 'Perl-Webdriver'
  6. Paste this entire source in the main textbox
  7. Click 'Save'
  8. Click 'Ok'
  9. Close Selenium IDE and open it again.

Support and Documentation

There is a mailing list available at!forum/selenium-remote-driver

for usage questions and ensuing discussions. If you've come across a bug, please open an issue in the Github issue tracker. The POD is available in the usual places, including metacpan, and in your shell via perldoc.

$ perldoc Selenium::Remote::Driver
$ perldoc Selenium::Remote::WebElement


Thanks for considering contributing! The contributing guidelines are in the wiki. The documentation there also includes information on generating new Linux recordings for Travis.

Copyright and License

Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child

Copyright (c) 2014-2016 Daniel Gempesaw

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.