Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teodesian/selenium-pageobjects-perl
Perl module/class to help create Page Objects. Analogous to Selenium's PageFactory Class.
https://github.com/teodesian/selenium-pageobjects-perl
Last synced: 28 days ago
JSON representation
Perl module/class to help create Page Objects. Analogous to Selenium's PageFactory Class.
- Host: GitHub
- URL: https://github.com/teodesian/selenium-pageobjects-perl
- Owner: teodesian
- Created: 2014-07-29T20:00:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-11T20:16:47.000Z (over 9 years ago)
- Last Synced: 2024-03-18T15:31:47.859Z (8 months ago)
- Language: Perl
- Size: 521 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
Selenium-PageObjects-Perl
=========================Perl module/class to help create Page Objects. Analogous to Selenium's PageFactory Class.
Can use both WWW::Selenium and Selenium::Remote::Driver objects as drivers.See:
https://code.google.com/p/selenium/wiki/PageFactory for info about PageFactory
and
https://code.google.com/p/selenium/wiki/PageObjects
for more info about page objects themselves.Example Usage:
> package SomePage;
>
> use Selenium::PageObject;
>
> our @ISA = qw(SeleniumPageObject);
>
>
> sub new {
>
> my ($class,$driver);
>
> return $class->SUPER::new($class,$driver,"/somepage.html");
>
> }
>
>
> sub doStuff {
>
> my ($self,$stuff2type,$option2select);
>
> my $textBox = $self->SUPER::getElement('someBox','id');
>
> my $customResult = $textBox->set($stuff2type,sub {
>
> my $self = shift; #full access to parent page object
>
> $self->dismissAlert(); #Callback to dismiss stupid alert that pops up when we type stuff into this box...
>
> return $self->driver->doSomethingSpecificToMyDriverModule('foo'); #While the underlying driver is always available, you should avoid doing this in pageObjects you expect to work with any driver module.
>
> });
>
>
> my $successes = 0;
>
> my $count = scalar(@listboxes);
>
> my @listBoxes = $self->SUPER::getElement('.listbox','class');
>
> foreach my $box (@listboxes) {
>
> #Set all boxes to have the relevant element selected.
>
> unless ($box->isSelect) {
>
> $count--;
>
> next;
>
> }
>
> warn "box has no glarch option" unless $box->hasOptions($options2select));
>
> $successes += $box->set($option2select); #returns 1 or 0 depending on whether it could set it or not
>
> }
>
> return !($count - $success); # if successes = num of listboxes, yay
>
> }
>
>
> sub Submit {
>
> my $self = shift;
>
> return $self->SUPER::submit('someButton','id',sub {...}); #Callback to handle whatever we think a successful submission does
>
> }How the test author should end up using this:
> use Selenium::Remote::Driver;
>
> use SomePage; #The module we made above
>
> my $webDriver = Selenium::Remote::Driver->new({'remote_server_addr' => 'localhost');
>
> $webDriver->get('http://my-app.test/');
>
> my $somePage = SomePage->new($webDriver);
>
> $somePage->doStuff('blah','someOption');
>
> ok($somePage->Submit(),"Page did needful");Refer to the POD for futher information.