AnyEvent-WebDriver
view release on metacpan or search on metacpan
WebDriver.pm view on Meta::CPAN
=cut
our %USING = (
css => "css selector",
link => "link text",
substr => "partial link text",
tag => "tag name",
);
sub _using($) {
using => $USING{$_[0]} // "$_[0]"
}
=item $element = $wd->find_element ($locator_strategy, $selector)
Finds the first element specified by the given selector and returns its
element object. Raises an error when no element was found.
Examples showing all standard locator strategies:
WebDriver.pm view on Meta::CPAN
Example: define a new touch device called C<fatfinger>.
$al->source (fatfinger => "pointer", pointerType => "touch");
Example: switch default keyboard source to C<kbd1>, assuming it is of C<key> class.
$al->source ("kbd1");
=cut
sub _default_source($) {
my ($source) = @_;
$source eq "keyboard" ? { actions => [], id => $source, type => "key" }
: $source eq "mouse" ? { actions => [], id => $source, type => "pointer", pointerType => "mouse" }
: $source eq "touch" ? { actions => [], id => $source, type => "pointer", pointerType => "touch" }
: $source eq "pen" ? { actions => [], id => $source, type => "pointer", pointerType => "pen" }
: Carp::croak "AnyEvent::WebDriver::Actions: event source '$source' not defined"
}
my %source_class = (
WebDriver.pm view on Meta::CPAN
"\uE007" "NumpadEnter"
"\uE024" "NumpadMultiply"
"\uE027" "NumpadSubtract"
"\uE03D" "MetaLeft"
"\uE053" "MetaRight"
EOF
our %SPECIAL_KEY;
sub _special_key($) {
# parse first time
%SPECIAL_KEY || do {
for (split /\n/, $SPECIAL_KEY) {
s/"//g or next;
my ($k, $s, $name) = split /\t/;
# unescape \uXXXX, convert string to codepoint
$_ = /^\\u/ ? hex substr $_, 2 : ord
for $k, $s;
WebDriver.pm view on Meta::CPAN
}
undef $SPECIAL_KEY; # save memory
};
exists $SPECIAL_KEY{$_[0]}
? chr $SPECIAL_KEY{$_[0]}
: Carp::croak "AnyEvent::WebDriver::Actions: special key '$1' not known"
}
sub _kv($) {
$_[0] =~ /^\{(.*)\}$/s
? _special_key $1
: $_[0]
}
sub key_down {
my ($self, $key, $source) = @_;
$self->_add ($source, kbd => keyDown => value => _kv $key)
}
( run in 0.741 second using v1.01-cache-2.11-cpan-65fba6d93b7 )