AnyEvent-WebDriver
view release on metacpan or search on metacpan
WebDriver.pm view on Meta::CPAN
Returns the element rect(angle) of the given element.
=item $bool = $wd->is_element_enabled
Returns whether the element is enabled or not.
=cut
sub is_element_selected_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/selected" => $_[2]);
}
sub get_element_attribute_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/attribute/$_[2]" => $_[3]);
}
sub get_element_property_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/property/$_[2]" => $_[3]);
}
sub get_element_css_value_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/css/$_[2]" => $_[3]);
}
sub get_element_text_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/text" => $_[2]);
}
sub get_element_tag_name_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/name" => $_[2]);
}
sub get_element_rect_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/rect" => $_[2]);
}
sub is_element_enabled_ {
$_[0]->get_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/enabled" => $_[2]);
}
=back
=head3 ELEMENT INTERACTION
=over
=cut
=item $wd->element_click ($element)
Clicks the given element.
=item $wd->element_clear ($element)
Clear the contents of the given element.
=item $wd->element_send_keys ($element, $text)
Sends the given text as key events to the given element. Key input state
can be cleared by embedding C<\x{e000}> in C<$text>. Presumably, you can
embed modifiers using their unicode codepoints, but the specification is
less than clear to mein this area.
=cut
sub element_click_ {
$_[0]->post_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/click" => undef, $_[2]);
}
sub element_clear_ {
$_[0]->post_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/clear" => undef, $_[2]);
}
sub element_send_keys_ {
$_[0]->post_ ("element/$_[1]{$WEB_ELEMENT_IDENTIFIER}/value" => { text => "$_[2]" }, $_[3]);
}
=back
=head3 DOCUMENT HANDLING
=over
=cut
=item $source = $wd->get_page_source
Returns the (HTML/XML) page source of the current document.
=item $results = $wd->execute_script ($javascript, $args)
Synchronously execute the given script with given arguments and return its
results (C<$args> can be C<undef> if no arguments are wanted/needed).
$ten = $wd->execute_script ("return arguments[0]+arguments[1]", [3, 7]);
=item $results = $wd->execute_async_script ($javascript, $args)
Similar to C<execute_script>, but doesn't wait for script to return, but
instead waits for the script to call its last argument, which is added to
C<$args> automatically.
$twenty = $wd->execute_async_script ("arguments[0](20)", undef);
=cut
sub get_page_source_ {
$_[0]->get_ (source => $_[1]);
}
sub execute_script_ {
$_[0]->post_ ("execute/sync" => { script => "$_[1]", args => $_[2] || [] }, $_[3]);
}
sub execute_async_script_ {
$_[0]->post_ ("execute/async" => { script => "$_[1]", args => $_[2] || [] }, $_[3]);
}
=back
=head3 COOKIES
WebDriver.pm view on Meta::CPAN
}
=item $al = $al->move ($origin, $x, $y, $duration, $source)
Moves a pointer to the given position, relative to origin (either
"viewport", "pointer" or an element object. The coordinates will be
truncated to integer values.
=cut
sub move {
my ($self, $origin, $x, $y, $duration, $source) = @_;
$self->_add ($source, ptr => pointerMove =>
origin => $origin, x => int $x*1, y => int $y*1, duration => $duration*1)
}
=item $al = $al->cancel ($source)
Executes a pointer cancel action.
=cut
sub cancel {
my ($self, $source) = @_;
$self->_add ($source, ptr => "pointerCancel")
}
=item $al = $al->key_down ($key, $source)
=item $al = $al->key_up ($key, $source)
Press or release the given key.
=item $al = $al->key ($key, $source)
Peess and release the given key in one go, without unnecessary delay.
A special syntax, C<{keyname}> can be used for special keys -
all the special key names from L<the second table in section
17.4.2|https://www.w3.org/TR/webdriver1/#keyboard-actions> of the
WebDriver recommendation can be used - prefix with C<Shift-Space>. to get
the shifted version, as in C<Shift-
Example: press and release "a".
$al->key ("a");
Example: press and release the "Enter" key:
$al->key ("\x{e007}");
Example: press and release the "enter" key using the special key name syntax:
$al->key ("{Enter}");
=item $al = $al->type ($string, $source)
Convenience method to simulate a series of key press and release events
for the keys in C<$string>, one pair per extended unicode grapheme
cluster. There is no syntax for special keys, everything will be typed
"as-is" if possible.
=cut
# copy&paste from the spec via browser, with added MetaLeft/MetaRight aliases
our $SPECIAL_KEY = <<'EOF';
"`" "~" "Backquote"
"\" "|" "Backslash"
"\uE003" "Backspace"
"[" "{" "BracketLeft"
"]" "}" "BracketRight"
"," "<" "Comma"
"0" ")" "Digit0"
"1" "!" "Digit1"
"2" "@" "Digit2"
"3" "#" "Digit3"
"4" "$" "Digit4"
"5" "%" "Digit5"
"6" "^" "Digit6"
"7" "&" "Digit7"
"8" "*" "Digit8"
"9" "(" "Digit9"
"=" "+" "Equal"
"<" ">" "IntlBackslash"
"a" "A" "KeyA"
"b" "B" "KeyB"
"c" "C" "KeyC"
"d" "D" "KeyD"
"e" "E" "KeyE"
"f" "F" "KeyF"
"g" "G" "KeyG"
"h" "H" "KeyH"
"i" "I" "KeyI"
"j" "J" "KeyJ"
"k" "K" "KeyK"
"l" "L" "KeyL"
"m" "M" "KeyM"
"n" "N" "KeyN"
"o" "O" "KeyO"
"p" "P" "KeyP"
"q" "Q" "KeyQ"
"r" "R" "KeyR"
"s" "S" "KeyS"
"t" "T" "KeyT"
"u" "U" "KeyU"
"v" "V" "KeyV"
"w" "W" "KeyW"
"x" "X" "KeyX"
"y" "Y" "KeyY"
"z" "Z" "KeyZ"
"-" "_" "Minus"
"." ">"." "Period"
"'" """ "Quote"
";" ":" "Semicolon"
"/" "?" "Slash"
"\uE00A" "AltLeft"
"\uE052" "AltRight"
"\uE009" "ControlLeft"
"\uE051" "ControlRight"
( run in 2.451 seconds using v1.01-cache-2.11-cpan-d7f47b0818f )