AnyEvent-WebDriver
view release on metacpan or search on metacpan
WebDriver.pm view on Meta::CPAN
sub fullscreen_window_ {
$_[0]->post_ ("window/fullscreen" => undef, $_[1]);
}
=back
=head3 ELEMENT RETRIEVAL
To reduce typing and memory strain, the element finding functions accept
some shorter and hopefully easier to remember aliases for the standard
locator strategy values, as follows:
Alias Locator Strategy
css css selector
link link text
substr partial link text
tag tag name
=over
=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:
$element = $wd->find_element ("css selector" => "body a");
$element = $wd->find_element ("link text" => "Click Here For Porn");
$element = $wd->find_element ("partial link text" => "orn");
$element = $wd->find_element ("tag name" => "input");
$element = $wd->find_element ("xpath" => '//input[@type="text"]');
=> e.g. { "element-6066-11e4-a52e-4f735466cecf" => "decddca8-5986-4e1d-8c93-efe952505a5f" }
Same examples using aliases provided by this module:
$element = $wd->find_element (css => "body a");
$element = $wd->find_element (link => "Click Here For Porn");
$element = $wd->find_element (substr => "orn");
$element = $wd->find_element (tag => "input");
=item $elements = $wd->find_elements ($locator_strategy, $selector)
As above, but returns an arrayref of all found element objects.
=item $element = $wd->find_element_from_element ($element, $locator_strategy, $selector)
Like C<find_element>, but looks only inside the specified C<$element>.
=item $elements = $wd->find_elements_from_element ($element, $locator_strategy, $selector)
Like C<find_elements>, but looks only inside the specified C<$element>.
my $head = $wd->find_element ("tag name" => "head");
my $links = $wd->find_elements_from_element ($head, "tag name", "link");
=item $element = $wd->get_active_element
Returns the active element.
=cut
sub find_element_ {
$_[0]->post_ (element => { _using $_[1], value => "$_[2]" }, $_[3]);
}
sub find_elements_ {
$_[0]->post_ (elements => { _using $_[1], value => "$_[2]" }, $_[3]);
}
sub find_element_from_element_ {
$_[0]->post_ ("element/$_[1]/element" => { _using $_[2], value => "$_[3]" }, $_[4]);
}
sub find_elements_from_element_ {
$_[0]->post_ ("element/$_[1]/elements" => { _using $_[2], value => "$_[3]" }, $_[4]);
}
sub get_active_element_ {
$_[0]->get_ ("element/active" => $_[1]);
}
=back
=head3 ELEMENT STATE
=over
=cut
=item $bool = $wd->is_element_selected
Returns whether the given input or option element is selected or not.
=item $string = $wd->get_element_attribute ($element, $name)
Returns the value of the given attribute.
=item $string = $wd->get_element_property ($element, $name)
Returns the value of the given property.
=item $string = $wd->get_element_css_value ($element, $name)
Returns the value of the given CSS value.
=item $string = $wd->get_element_text ($element)
Returns the (rendered) text content of the given element.
=item $string = $wd->get_element_tag_name ($element)
( run in 1.451 second using v1.01-cache-2.11-cpan-39bf76dae61 )