Module: Webdriver
Overview
Webdriver defines all the Webdriver methods in a module so that they can be included by other classes
Instance Method Summary collapse
-
#click?(attrs = {}) ⇒ Boolean
Public: Clicks the specified element.
-
#close? ⇒ Boolean
Public: Closes the browser.
-
#double_click?(attrs = {}) ⇒ Boolean
Public: Double-clicks the specified element.
-
#forward? ⇒ Boolean
Public: Navigates forward.
-
#navigate?(url) ⇒ Boolean
Public: Navigates to the specified screen or URL.
-
#refresh? ⇒ Boolean
Public: Refreshes the current URL.
-
#send?(keys, attrs = {}) ⇒ Boolean
Public: Sends the given keys to the specified element.
-
#type?(keys, attrs = {}) ⇒ Boolean
Public: Types the given text in the specified element.
Methods included from Selenium
#back?, #element, #element?, #elements, #elements?, #time_to_element, #time_to_elements
Instance Method Details
#click?(attrs = {}) ⇒ Boolean
Public: Clicks the specified element.
For any String criteria, a Regular Expression may be used by adding the 'regexp:' prefix.
selector - String CSS selector to locate the element (default: nil). id - String element id (default: nil). class_name - String element class name (default: nil). tag_name - String element tag name (default: nil). value - String element value (default: nil). name - String element name (default: nil). text - String element text (default: nil). xpath - String xpath to locate the element (default: nil).
NOTE: xpath is unreliable and should be used sparingly.
type - String type of the element (default: nil). description - String description of the element (default: nil). index - Integer index of element to use among all matching elements (default: nil).
By default, exactly one element must match.
is_visible - Boolean indicating whether the element is visible (default: nil). is_on_screen - Boolean indicating whether any part of the element is within screen boundaries (default: nil). is_tappable - Boolean indicating whether the element may be tapped (default: nil). is_password - Boolean indicating whether the element is a password field (default: nil). is_enabled - Boolean indicating whether the element is enabled (default: nil). is_checked - Boolean indicating whether the element is checked (default: nil). is_selected - Boolean indicating whether the element is selected (default: nil). is_checkable - Boolean indicating whether the element can be checked (default: nil). is_focusable - Boolean indicating whether the element can be focused (default: nil). is_long_pressable - Boolean indicating whether the element can be long-pressed (default: nil). is_scrollable - Boolean indicating whether the element can be scrolled (default: nil). is_recordable - Boolean indicating whether the element can be recorded (default: nil). x - Integer x coordinate of the element (default: nil). y - Integer y coordinate of the element (default: nil). width - Integer width of the element (default: nil). height - Integer height of the element (default: nil). coordinates - Boolean indicating whether absolute coordinates are given (default: false). min - Integer minimum number of matching elements to require (default: 0).
By default, no restriction is imposed.
max - Integer maximum number of matching elements to require (default: nil).
By default, no restriction is imposed.
timeout - Integer total milliseconds to allow for element search (default: 30.sec).
Returns a Boolean true if successfully clicked the element, otherwise false.
89 90 91 92 |
# File 'lib/selenium/webdriver/webdriver.rb', line 89 def click?(attrs={}) ret = selenium_post('click', attrs) !ret.nil? end |
#close? ⇒ Boolean
Public: Closes the browser.
Returns a Boolean true if successfully closed the browser, otherwise false.
39 40 41 42 43 44 45 46 47 |
# File 'lib/selenium/webdriver/webdriver.rb', line 39 def close? ret = selenium_delete(nil, {}) if ret.nil? false else @closed = true true end end |
#double_click?(attrs = {}) ⇒ Boolean
Public: Double-clicks the specified element.
For any String criteria, a Regular Expression may be used by adding the 'regexp:' prefix.
delay - Integer delay between clicks in milliseconds (default: 100.ms). selector - String CSS selector to locate the element (default: nil). id - String element id (default: nil). class_name - String element class name (default: nil). tag_name - String element tag name (default: nil). value - String element value (default: nil). name - String element name (default: nil). text - String element text (default: nil). xpath - String xpath to locate the element (default: nil).
NOTE: xpath is unreliable and should be used sparingly.
type - String type of the element (default: nil). description - String description of the element (default: nil). index - Integer index of element to use among all matching elements (default: nil).
By default, exactly one element must match.
is_visible - Boolean indicating whether the element is visible (default: nil). is_on_screen - Boolean indicating whether any part of the element is within screen boundaries (default: nil). is_tappable - Boolean indicating whether the element may be tapped (default: nil). is_password - Boolean indicating whether the element is a password field (default: nil). is_enabled - Boolean indicating whether the element is enabled (default: nil). is_checked - Boolean indicating whether the element is checked (default: nil). is_selected - Boolean indicating whether the element is selected (default: nil). is_checkable - Boolean indicating whether the element can be checked (default: nil). is_focusable - Boolean indicating whether the element can be focused (default: nil). is_long_pressable - Boolean indicating whether the element can be long-pressed (default: nil). is_scrollable - Boolean indicating whether the element can be scrolled (default: nil). is_recordable - Boolean indicating whether the element can be recorded (default: nil). x - Integer x coordinate of the element (default: nil). y - Integer y coordinate of the element (default: nil). width - Integer width of the element (default: nil). height - Integer height of the element (default: nil). coordinates - Boolean indicating whether absolute coordinates are given (default: false). min - Integer minimum number of matching elements to require (default: 0).
By default, no restriction is imposed.
max - Integer maximum number of matching elements to require (default: nil).
By default, no restriction is imposed.
timeout - Integer total milliseconds to allow for element search (default: 30.sec).
Returns a Boolean true if successfully double-clicked the element, otherwise false.
135 136 137 138 |
# File 'lib/selenium/webdriver/webdriver.rb', line 135 def double_click?(attrs={}) ret = selenium_post('double-click', attrs) !ret.nil? end |
#forward? ⇒ Boolean
Public: Navigates forward.
Returns a Boolean true if successfully pressed Forward, otherwise false.
13 14 15 16 |
# File 'lib/selenium/webdriver/webdriver.rb', line 13 def forward? ret = selenium_post('forward', {}) !ret.nil? end |
#navigate?(url) ⇒ Boolean
Public: Navigates to the specified screen or URL.
url - String URL to navigate to.
Returns a Boolean true if successfully pressed Refresh, otherwise false.
31 32 33 34 |
# File 'lib/selenium/webdriver/webdriver.rb', line 31 def navigate?(url) ret = selenium_post('navigate', {:url => url}) !ret.nil? end |
#refresh? ⇒ Boolean
Public: Refreshes the current URL.
Returns a Boolean true if successfully pressed Refresh, otherwise false.
21 22 23 24 |
# File 'lib/selenium/webdriver/webdriver.rb', line 21 def refresh? ret = selenium_post('refresh', {}) !ret.nil? end |
#send?(keys, attrs = {}) ⇒ Boolean
Public: Sends the given keys to the specified element.
For any String criteria, a Regular Expression may be used by adding the 'regexp:' prefix.
keys - String or Array of String keys to send. combine - Boolean indicating whether the keys should be combined (default: false).
This should be used to send combinations like `Control+A'. The following keys are supported:
https://seleniumhq.github.io/selenium/docs/api/dotnet/html/T_OpenQA_Selenium_Keys.htm
selector - String CSS selector to locate the element (default: nil). id - String element id (default: nil). class_name - String element class name (default: nil). tag_name - String element tag name (default: nil). value - String element value (default: nil). name - String element name (default: nil). text - String element text (default: nil). xpath - String xpath to locate the element (default: nil).
NOTE: xpath is unreliable and should be used sparingly.
type - String type of the element (default: nil). description - String description of the element (default: nil). index - Integer index of element to use among all matching elements (default: nil).
By default, exactly one element must match.
is_visible - Boolean indicating whether the element is visible (default: nil). is_on_screen - Boolean indicating whether any part of the element is within screen boundaries (default: nil). is_tappable - Boolean indicating whether the element may be tapped (default: nil). is_password - Boolean indicating whether the element is a password field (default: nil). is_enabled - Boolean indicating whether the element is enabled (default: nil). is_checked - Boolean indicating whether the element is checked (default: nil). is_selected - Boolean indicating whether the element is selected (default: nil). is_checkable - Boolean indicating whether the element can be checked (default: nil). is_focusable - Boolean indicating whether the element can be focused (default: nil). is_long_pressable - Boolean indicating whether the element can be long-pressed (default: nil). is_scrollable - Boolean indicating whether the element can be scrolled (default: nil). is_recordable - Boolean indicating whether the element can be recorded (default: nil). x - Integer x coordinate of the element (default: nil). y - Integer y coordinate of the element (default: nil). width - Integer width of the element (default: nil). height - Integer height of the element (default: nil). coordinates - Boolean indicating whether absolute coordinates are given (default: false). min - Integer minimum number of matching elements to require (default: 0).
By default, no restriction is imposed.
max - Integer maximum number of matching elements to require (default: nil).
By default, no restriction is imposed.
timeout - Integer total milliseconds to allow for element search (default: 30.sec).
Returns a Boolean true if successfully typed in the element, otherwise false.
235 236 237 238 239 240 241 242 243 |
# File 'lib/selenium/webdriver/webdriver.rb', line 235 def send?(keys, attrs={}) if keys.is_a?(Array) attrs[:keys] = keys else attrs[:keys] = [keys] end ret = selenium_post('send', attrs) !ret.nil? end |
#type?(keys, attrs = {}) ⇒ Boolean
Public: Types the given text in the specified element.
For any String criteria, a Regular Expression may be used by adding the 'regexp:' prefix.
keys - String or Array of String keys to type. selector - String CSS selector to locate the element (default: nil). id - String element id (default: nil). class_name - String element class name (default: nil). tag_name - String element tag name (default: nil). value - String element value (default: nil). name - String element name (default: nil). text - String element text (default: nil). xpath - String xpath to locate the element (default: nil).
NOTE: xpath is unreliable and should be used sparingly.
type - String type of the element (default: nil). description - String description of the element (default: nil). index - Integer index of element to use among all matching elements (default: nil).
By default, exactly one element must match.
is_visible - Boolean indicating whether the element is visible (default: nil). is_on_screen - Boolean indicating whether any part of the element is within screen boundaries (default: nil). is_tappable - Boolean indicating whether the element may be tapped (default: nil). is_password - Boolean indicating whether the element is a password field (default: nil). is_enabled - Boolean indicating whether the element is enabled (default: nil). is_checked - Boolean indicating whether the element is checked (default: nil). is_selected - Boolean indicating whether the element is selected (default: nil). is_checkable - Boolean indicating whether the element can be checked (default: nil). is_focusable - Boolean indicating whether the element can be focused (default: nil). is_long_pressable - Boolean indicating whether the element can be long-pressed (default: nil). is_scrollable - Boolean indicating whether the element can be scrolled (default: nil). is_recordable - Boolean indicating whether the element can be recorded (default: nil). x - Integer x coordinate of the element (default: nil). y - Integer y coordinate of the element (default: nil). width - Integer width of the element (default: nil). height - Integer height of the element (default: nil). coordinates - Boolean indicating whether absolute coordinates are given (default: false). min - Integer minimum number of matching elements to require (default: 0).
By default, no restriction is imposed.
max - Integer maximum number of matching elements to require (default: nil).
By default, no restriction is imposed.
timeout - Integer total milliseconds to allow for element search (default: 30.sec).
Returns a Boolean true if successfully typed in the element, otherwise false.
181 182 183 184 185 186 187 188 189 |
# File 'lib/selenium/webdriver/webdriver.rb', line 181 def type?(keys, attrs={}) if keys.is_a?(Array) attrs[:keys] = keys else attrs[:keys] = keys.split('') end ret = selenium_post('type', attrs) !ret.nil? end |