NAME
Selenium::Element - Unified way of interacting with Selenium & WebDriver elements, with a focus on inputs.
SYNOPSIS
Smooths out the interface between WWW::Selenium and Selenium::Remote::Driver elements. Also creates a unified set/get interface for all inputs.
CONSTRUCTOR
new(ELEMENT,DRIVER,SELECTOR)
Create a new Selenium::Element. You should never have to use/override this except in the most extreme of circumstances. Use getElement/getElements instead.
INPUTS:
ELEMENT (MIXED) - Either the WWW::Selenium locator string or a Selenium::Remote::WebElement, depending on your driver
DRIVER (MIXED) - Either a WWW::Selenium element or false, depending on your driver (the WebElement has the driver in the latter case)
SELECTOR (ARRAYREF[string]) - Arrayref of the form [selector,selectortype]
OUTPUT:
new Selenium::Element
GETTERS
get_tag_name
Returns the tag name of the Element object.
get_type
Returns the type of the Element object if it is an input tag.
is_input
Returns whether the element is an input.
is_textinput
Returns whether the element is an input with type 'text' or 'password' or a textarea.
is_select
Returns whether the element is a select.
is_multiselect
Returns whether the element is a select with the 'multiple' attribute.
is_radio
Returns whether the element is a radio button.
is_checkbox
Returns whether the element is a checkbox.
is_submit
Returns whether the element is an input of the type 'submit'.
is_fileinput
Returns whether the element is an input of the type 'file'.
is_fileinput
Returns whether the element is an input of the type 'file'.
is_option
Returns whether the element is an option.
is_hiddeninput
Returns whether the element is an input of type 'hidden'.
is_enabled
Returns whether the element is a disabled input.
get_options
Returns a list containing Selenium::Element objects that are child options, if this object is a select.
has_option(option)
Returns whether this element has a child option with the provided name, provided this object is a select.
INPUT: OPTION (STRING) - the name of the desired option
OUTPUT: BOOLEAN - whether this object has said option as a child
is_selected
Returns whether the element is selected.
get
Returns the current value of the element.
OUTPUT:
MIXED - Depends on the type of element. Boolean for checkboxes, options and radiobuttons Arrayrefs of option names for multi-selects Strings for single selects, text/hidden inputs and non-inputs like paragraphs, table cells, etc.
id
Returns the element's id.
name
Returns the element's name.
SETTERS
clear
Clear a text input.
set(value,[callback])
Set the value of the input to the provided value, and execute the provided callback if provided. The callback will be provided with the caller and the selenium driver as arguments.
INPUT:
VALUE (MIXED) - STRING, BOOLEAN or ARRAYREF, depending on the type of element you are attempting to set. Strings are for textinputs, hiddens or non-multi selects, Booleans for radiobuttons, checkboxes and options, and Arrayrefs of strings for multiselects. Selects take the name of the option as arguments.
CALLBACK (CODE) [optional] - some anonymous function
OUTPUT:
MIXED - whether the set succeeded, or whatever your callback feels like returning, supposing you provided one.
randomize(options)
Randomizes the input, depending on the type of element. Useful for fuzzing.
INPUT:
HASH: Options appropraite to the relevant Data::Random method.
OUTPUT:
MIXED - Random value that has been set into the field, or false on failure.
STATE CHANGE METHODS
javascript(js)
Execute an arbitrary Javascript string and return the output. Handy in callbacks that wait for JS events.
INPUT:
JS (STRING) - any valid javascript string
OUTPUT:
MIXED - depends on your javascript's output.
click
Click the element.
submit([callback])
Submit the element, supposing it's a form
INPUT:
CALLBACK (CODE) [optional] - anonymous function
OUPUT:
MIXED - Whether the action succeeded or whatever your callback returns, supposing it was provided.
SEE ALSO
AUTHOR
George S. Baugh <teodesian@cpan.org>
SPECIAL THANKS
cPanel, Inc. graciously funded the initial work on this Module.
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by George S. Baugh.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.