|
|
@@ -8,15 +8,21 @@ use Selenium::Remote::Mock::RemoteConnection;
|
|
|
|
|
|
my $spec = {
|
|
|
findElement => sub {
|
|
|
- my (undef,$searched_item) = @_;
|
|
|
- return { status => 'OK', return => { ELEMENT => '123456' } }
|
|
|
- if ( $searched_item->{value} eq 'q' );
|
|
|
+ my ( undef, $searched_item ) = @_;
|
|
|
+ if ( $searched_item->{value} eq 'q' ) {
|
|
|
+ return { status => 'OK', return => { ELEMENT => '123456' } };
|
|
|
+ }
|
|
|
+ if ( $searched_item->{value} eq 'p'
|
|
|
+ && $searched_item->{using} eq 'class name' )
|
|
|
+ {
|
|
|
+ return { status => 'OK', return => { ELEMENT => '123456' } };
|
|
|
+ }
|
|
|
return { status => 'NOK', return => 0, error => 'element not found' };
|
|
|
- },
|
|
|
+ },
|
|
|
getPageSource => sub { return 'this output matches regex'},
|
|
|
findElements => sub {
|
|
|
my (undef,$searched_expr) = @_;
|
|
|
- if ($searched_expr) {
|
|
|
+ if ($searched_expr->{value} eq 'abc' && $searched_expr->{using} eq 'xpath') {
|
|
|
return { status => 'OK', return => [ { ELEMENT => '123456' }, { ELEMENT => '12341234' } ] }
|
|
|
}
|
|
|
},
|
|
|
@@ -29,6 +35,7 @@ my $successful_driver =
|
|
|
commands => $mock_commands,
|
|
|
);
|
|
|
$successful_driver->find_element_ok('q','find_element_ok works');
|
|
|
+$successful_driver->find_element_ok('p','class','find_element_ok with a locator works');
|
|
|
dies_ok { $successful_driver->find_element_ok('notq') } 'find_element_ok dies if element not found';
|
|
|
$successful_driver->find_no_element_ok('notq','find_no_element_ok works');
|
|
|
$successful_driver->content_like( qr/matches/, 'content_like works');
|