|
|
10 лет назад | |
|---|---|---|
| lib | 10 лет назад | |
| t | 10 лет назад | |
| .gitignore | 11 лет назад | |
| .mailmap | 11 лет назад | |
| .travis.yml | 11 лет назад | |
| Changes | 10 лет назад | |
| INSTALL.md | 10 лет назад | |
| README.md | 10 лет назад | |
| TAGS | 11 лет назад | |
| cpanfile | 10 лет назад | |
| dist.ini | 10 лет назад | |
| driver-example.pl | 12 лет назад | |
| ide-plugin.js | 12 лет назад | |
| weaver.ini | 11 лет назад |
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.
This module sends commands directly to the server using HTTP. Using this module together with the Selenium Server, you can automatically control any supported browser. To use this module, you need to have already downloaded and started the standalone Selenium Server.
It's probably easiest to use the cpanm or CPAN commands:
$ cpanm Selenium::Remote::Driver
If you want to install from this repository, you have a few options; see the installation docs for more details.
For Firefox: simply have the browser installed in the normal place for your OS.
my $firefox = Selenium::Firefox->new;
$firefox->get('http://www.google.com');
For Chrome: install the chrome browser and download Chromedriver
my $chrome = Selenium::Chrome->new;
$chrome->get('http://www.google.com');
Download the standalone server and have it running on port 4444; then the following should start up Firefox for you:
#! /usr/bin/perl
use strict;
use warnings;
use Selenium::Remote::Driver;
my $driver = Selenium::Remote::Driver->new;
$driver->get('http://www.google.com');
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');
$send_search->click;
# make the find_element blocking for a second to allow the title to change
$driver->set_implicit_wait_timeout(2000);
my $results = $driver->find_element('search', 'id');
print $driver->get_title . "\n"; # CPAN Selenium Remote Driver - Google Search
$driver->quit;
use Selenium::Remote::Driver;
my $user = $ENV{SAUCE_USERNAME};
my $key = $ENV{SAUCE_ACCESS_KEY};
my $driver = Selenium::Remote::Driver->new(
remote_server_addr => $user . ':' . $key . '@ondemand.saucelabs.com',
port => 80
);
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->quit();
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.
There is a new mailing list available at
https://groups.google.com/forum/#!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 also in the wiki. The documentation there also includes information on generating new recordings via
$ perl t/bin/record.pl
Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child
Copyright (c) 2014 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
http://www.apache.org/licenses/LICENSE-2.0
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.