This is an automated email from the git hooks/post-receive script. jame-guest pushed a commit to tag v0.02 in repository libweasel-perl.
commit b6afca1f7c2e7aca9b8cb0857d1d1abde8a33b55 Author: Erik Huelsmann <[email protected]> Date: Fri Jun 17 22:52:50 2016 +0200 * Implement APIs and fixes from testing New APIs: - get_attribute - get_text - tag_name - is_displayed --- lib/Weasel/DriverRole.pm | 16 +++++++++++++++ lib/Weasel/Element.pm | 41 ++++++++++++++++++++++++++++++++++++++ lib/Weasel/FindExpanders.pm | 2 +- lib/Weasel/Session.pm | 42 ++++++++++++++++++++++++++++++++++++++- lib/Weasel/WidgetHandlers.pm | 15 ++++++++++---- lib/Weasel/Widgets/HTML/Select.pm | 2 +- 6 files changed, 111 insertions(+), 7 deletions(-) diff --git a/lib/Weasel/DriverRole.pm b/lib/Weasel/DriverRole.pm index 44644c2..c7dc40e 100644 --- a/lib/Weasel/DriverRole.pm +++ b/lib/Weasel/DriverRole.pm @@ -96,6 +96,14 @@ sub get { croak "Abstract interface method 'get' called"; } +=item is_displayed($element_id) + +=cut + +sub is_displayed { + croak "Abstract interface method 'is_displayed' called"; +} + =item wait_for( $callback ) =cut @@ -134,6 +142,14 @@ sub get_attribute { croak "Abstract interface method 'get_attribute' called"; } +=item get_text($element_id) + +=cut + +sub get_text { + croak "Abstract interface method 'get_text' called"; +} + =item set_attribute($element_id, $attribute_name, $value) =cut diff --git a/lib/Weasel/Element.pm b/lib/Weasel/Element.pm index b0ca329..5472c36 100644 --- a/lib/Weasel/Element.pm +++ b/lib/Weasel/Element.pm @@ -70,6 +70,37 @@ sub find_all { return $self->session->find_all($self, @args); } +=item get_attribute($attribute) + +=cut + +sub get_attribute { + my ($self, $attribute) = @_; + + return $self->session->get_attribute($self, $attribute); +} + +=item get_text() + +=cut + +sub get_text { + my ($self) = @_; + + return $self->session->get_text($self); +} + + +=item is_displayed + +=cut + +sub is_displayed { + my ($self) = @_; + + return $self->session->is_displayed($self); +} + =item click() =cut @@ -89,6 +120,16 @@ sub send_keys { $self->session->send_keys($self, @keys); } +=item tag_name() + +=cut + +sub tag_name { + my ($self) = @_; + + return $self->session->tag_name($self); +} + =back =cut diff --git a/lib/Weasel/FindExpanders.pm b/lib/Weasel/FindExpanders.pm index e231bff..6f52f58 100644 --- a/lib/Weasel/FindExpanders.pm +++ b/lib/Weasel/FindExpanders.pm @@ -73,7 +73,7 @@ sub expand_finder_pattern { my ($pattern, $args, $groups) = @_; return $pattern - if ! ($pattern =~ m/\*([^\|]+)/); + if ! ($pattern =~ m/^\*([^\|]+)/); my $name = $1; croak "No expansions registered (while expanding '$pattern')" diff --git a/lib/Weasel/Session.pm b/lib/Weasel/Session.pm index 9d71b1b..0c2559f 100644 --- a/lib/Weasel/Session.pm +++ b/lib/Weasel/Session.pm @@ -152,7 +152,7 @@ sub find_all { $expanded_pattern, $args{scheme}); print STDERR "found " . scalar(@rv) . " elements for $pattern " . (join(', ', %args)) . "\n"; - print STDERR ' - ' . ref($_) . "\n" for (@rv); + print STDERR ' - ' . ref($_) . " (" . $_->tag_name . ")\n" for (@rv); return wantarray ? @rv : \@rv; } @@ -173,6 +173,36 @@ sub get { $self->driver->get($url); } +=item get_attribute($element, $attribute) + +=cut + +sub get_attribute { + my ($self, $element, $attribute) = @_; + + return $self->driver->get_attribute($element->_id, $attribute); +} + +=item get_text($element) + +=cut + +sub get_text { + my ($self, $element) = @_; + + return $self->driver->get_text($element->_id); +} + +=item is_displayed($element) + +=cut + +sub is_displayed { + my ($self, $element) = @_; + + return $self->driver->is_displayed($element->_id); +} + =item screenshot($fh) =cut @@ -193,6 +223,16 @@ sub send_keys { $self->driver->send_keys($element->_id, @keys); } +=item tag_name($element) + +=cut + +sub tag_name { + my ($self, $element) = @_; + + return $self->driver->tag_name($element->_id); +} + =item wait_for($callback) Waits until $callback->() returns true, or C<wait_timeout> expires diff --git a/lib/Weasel/WidgetHandlers.pm b/lib/Weasel/WidgetHandlers.pm index 14d9474..fadb290 100644 --- a/lib/Weasel/WidgetHandlers.pm +++ b/lib/Weasel/WidgetHandlers.pm @@ -93,6 +93,12 @@ sub _cached_elem_att { : ($cache->{$att} = $driver->get_attribute($_id, $att)); } +sub _att_eq { + my ($att1, $att2) = @_; + + return ($att1 // '') eq ($att2 // ''); +} + sub best_match_handler_class { my ($driver, $_id, $groups) = @_; @@ -115,7 +121,7 @@ sub best_match_handler_class { if (exists $conditions->{classes}) { %{$elem_classes} = - map { $_ => 1 } + map { $_ => 1 } split /\s+/, ($driver->get_attribute($_id, 'class') // '') unless defined $elem_classes; @@ -129,9 +135,10 @@ sub best_match_handler_class { for my $att (keys %{$conditions->{attributes}}) { next handler - unless $conditions->{attributes}->{$att} - eq _cached_elem_att( - $elem_att_cache, $driver, $_id, $att); + unless _att_eq( + $conditions->{attributes}->{$att}, + _cached_elem_att( + $elem_att_cache, $driver, $_id, $att)); $match_count++; } diff --git a/lib/Weasel/Widgets/HTML/Select.pm b/lib/Weasel/Widgets/HTML/Select.pm index 1812fad..e28b391 100644 --- a/lib/Weasel/Widgets/HTML/Select.pm +++ b/lib/Weasel/Widgets/HTML/Select.pm @@ -54,7 +54,7 @@ sub find_option { my ($self, $text) = @_; my $popup = $self->_option_popup; - $popup->find('*option', text => $text); + return $popup->find('*option', text => $text); } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libweasel-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits
