new ( %opts )
This will create a new Test::WebDriver object, which subclasses Selenium::Remote::Driver. This subclass provides useful testing functions. It is modeled on Test::WWW::Selenium.
Environment vars can be used to specify options to pass to Selenium::Remote::Driver. ENV vars are prefixed with TWD_
.
Set the Selenium server address with $TWD_HOST
and $TWD_PORT
.
Pick which browser is used using the $TWD_BROWSER
, $TWD_VERSION
, $TWD_PLATFORM
, $TWD_JAVASCRIPT
, $TWD_EXTRA_CAPABILITIES
.
See Selenium::Driver::Remote for the meanings of these options.
server_is_running( $host, $port )
Returns true if a Selenium server is running. The host and port parameters are optional, and default to localhost:4444
.
Environment vars TWD_HOST
and TWD_PORT
can also be used to determine the server to check.
Glue Code
Below here are some methods that make things less easier or less wordy.
get_text
Get the text of a particular element. Wrapper around find_element()
get_body
Get the current text for the whole body.
get_location
Get the current URL.
get_location
Get the path part of the current browser location.
NOTES
For Best Practice - I recommend subclassing Test::WebDriver for your application, and then refactoring common or app specific methods into MyApp::WebDriver so that your test files do not have much duplication. As your app changes, you can update MyApp::WebDriver rather than all the individual test files.
AUTHORS
Created by: Luke Closs <lukec@cpan.org>, but inspired by Test::WWW::Selenium and it's authors.
CONTRIBUTORS
This work was sponsored by Prime Radiant, Inc.
COPYRIGHT AND LICENSE
Copyright (c) 2012 Prime Radiant, Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.