|
|
@@ -20,13 +20,13 @@ has _builder => (
|
|
|
|
|
|
# get back the key value from an already coerced finder (default finder)
|
|
|
|
|
|
-sub _get_finder_key {
|
|
|
- my $self = shift;
|
|
|
- my $finder_value = shift;
|
|
|
- foreach my $k (keys %{$self->FINDERS}) {
|
|
|
+sub _get_finder_key {
|
|
|
+ my $self = shift;
|
|
|
+ my $finder_value = shift;
|
|
|
+ foreach my $k (keys %{$self->FINDERS}) {
|
|
|
return $k if ($self->FINDERS->{$k} eq $finder_value);
|
|
|
}
|
|
|
- return;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
# main method for non ok tests
|
|
|
@@ -62,26 +62,26 @@ sub _check_ok {
|
|
|
try {
|
|
|
$num_of_args = $self->has_args($method);
|
|
|
@r_args = splice( @args, 0, $num_of_args );
|
|
|
- if ($method =~ m/^find(_no|_child)?_element/) {
|
|
|
- # case find_element_ok was called with no arguments
|
|
|
- if (scalar(@r_args) - $num_of_args == 1) {
|
|
|
+ if ($method =~ m/^find(_no|_child)?_element/) {
|
|
|
+ # case find_element_ok was called with no arguments
|
|
|
+ if (scalar(@r_args) - $num_of_args == 1) {
|
|
|
push @r_args, $self->_get_finder_key($self->default_finder);
|
|
|
}
|
|
|
- else {
|
|
|
+ else {
|
|
|
if (scalar(@r_args) == $num_of_args) {
|
|
|
# case find_element was called with no finder but
|
|
|
# a test description
|
|
|
- my $finder = $r_args[$num_of_args - 1];
|
|
|
+ my $finder = $r_args[$num_of_args - 1];
|
|
|
my @FINDERS = keys (%{$self->FINDERS});
|
|
|
- unless ( any { $finder eq $_ } @FINDERS) {
|
|
|
+ unless ( any { $finder eq $_ } @FINDERS) {
|
|
|
$r_args[$num_of_args - 1] = $self->_get_finder_key($self->default_finder);
|
|
|
- push @args, $finder;
|
|
|
+ push @args, $finder;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
# quick hack to fit 'find_no_element' into check_ok logic
|
|
|
- if ($method eq 'find_no_element') {
|
|
|
+ if ($method eq 'find_no_element') {
|
|
|
$real_method = $method;
|
|
|
|
|
|
# If we use `find_element` and find nothing, the error
|
|
|
@@ -96,11 +96,11 @@ sub _check_ok {
|
|
|
}
|
|
|
else {
|
|
|
$rv = 1;
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
else {
|
|
|
- $rv = $self->$method(@r_args);
|
|
|
- }
|
|
|
+ $rv = $self->$method(@r_args);
|
|
|
+ }
|
|
|
}
|
|
|
catch {
|
|
|
if ($real_method) {
|
|
|
@@ -120,8 +120,8 @@ sub _check_ok {
|
|
|
my $test_name = pop @args // $default_test_name;
|
|
|
|
|
|
# case when find_no_element found an element, we should croak
|
|
|
- if ($real_method eq 'find_no_element') {
|
|
|
- if (blessed($rv) && $rv->isa('Selenium::Remote::WebElement')) {
|
|
|
+ if ($real_method eq 'find_no_element') {
|
|
|
+ if (blessed($rv) && $rv->isa('Selenium::Remote::WebElement')) {
|
|
|
$self->croak($test_name);
|
|
|
}
|
|
|
}
|