AnyEvent-WebDriver
view release on metacpan or search on metacpan
<https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities
>, Chrome-specific capability documentation might be found here
<http://chromedriver.chromium.org/capabilities>, but the latest
release at the time of this writing (chromedriver 77) has
essentially no documentation about webdriver capabilities (even MDN
has better documentation about chromwedriver!)
If you have URLs for Safari/IE/Edge etc. capabilities, feel free to
tell me about them.
$wd->delete_session
Deletes the session - the WebDriver object must not be used after
this call (except for calling this method).
This method is always safe to call and will not do anything if there
is no active session.
$timeouts = $wd->get_timeouts
Get the current timeouts, e.g.:
my $timeouts = $wd->get_timeouts;
=> { implicit => 0, pageLoad => 300000, script => 30000 }
$wd->set_timeouts ($timeouts)
Sets one or more timeouts, e.g.:
$wd->set_timeouts ({ script => 60000 });
NAVIGATION
$wd->navigate_to ($url)
Navigates to the specified URL.
$url = $wd->get_current_url
Queries the current page URL as set by "navigate_to".
$wd->back
The equivalent of pressing "back" in the browser.
$wd->forward
The equivalent of pressing "forward" in the browser.
$wd->refresh
The equivalent of pressing "refresh" in the browser.
$title = $wd->get_title
Returns the current document title.
COMMAND CONTEXTS
$handle = $wd->get_window_handle
Returns the current window handle.
$wd->close_window
Closes the current browsing context.
$wd->switch_to_window ($handle)
Changes the current browsing context to the given window.
$handles = $wd->get_window_handles
Return the current window handles as an array-ref of handle IDs.
$handles = $wd->switch_to_frame ($frame)
Switch to the given frame identified by $frame, which must be either
"undef" to go back to the top-level browsing context, an integer to
select the nth subframe, or an element object.
$handles = $wd->switch_to_parent_frame
Switch to the parent frame.
$rect = $wd->get_window_rect
Return the current window rect(angle), e.g.:
$rect = $wd->get_window_rect
=> { height => 1040, width => 540, x => 0, y => 0 }
$wd->set_window_rect ($rect)
Sets the window rect(angle), e.g.:
$wd->set_window_rect ({ width => 780, height => 560 });
$wd->set_window_rect ({ x => 0, y => 0, width => 780, height => 560 });
$wd->maximize_window
$wd->minimize_window
$wd->fullscreen_window
Changes the window size by either maximising, minimising or making
it fullscreen. In my experience, this will timeout if no window
manager is running.
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
$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");
$elements = $wd->find_elements ($locator_strategy, $selector)
As above, but returns an arrayref of all found element objects.
$element = $wd->find_element_from_element ($element, $locator_strategy,
$selector)
Like "find_element", but looks only inside the specified $element.
$elements = $wd->find_elements_from_element ($element,
$locator_strategy, $selector)
( run in 0.991 second using v1.01-cache-2.11-cpan-df04353d9ac )