Class: Watir::Element
- Inherits:
-
Object
- Object
- Watir::Element
- Defined in:
- lib/angular_webdriver/protractor/watir_patch.rb
Overview
Note the element class is different on master.
Instance Method Summary collapse
-
#allowAnimations(value = nil) ⇒ Object
Invoke protractor.allowAnimations with freshly located element and optional value.
- #assert_enabled ⇒ Object
-
#assert_exists ⇒ Object
Ensure that the element exists by always relocating it Required to trigger waitForAngular.
- #assert_not_stale ⇒ Object
-
#clear ⇒ Object
Watir doesn’t define a clear method on element so we have to provide one.
-
#element_call ⇒ Object
Always raise on stale element ref error.
-
#evaluate(expression) ⇒ Object
Evaluate an Angular expression as if it were on the scope of the current element.
-
#locate ⇒ Object
avoid context lookup.
-
#locator ⇒ Object
Return original selector.
-
#present? ⇒ Boolean
Returns true if the element exists and is visible on the page.
- #selected? ⇒ Boolean
-
#to_json(*args) ⇒ Object
private
required for watir otherwise execute_script will fail.
Instance Method Details
#allowAnimations(value = nil) ⇒ Object
Invoke protractor.allowAnimations with freshly located element and optional value.
115 116 117 118 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 115 def allowAnimations value=nil assert_exists driver.protractor.allowAnimations @element, value end |
#assert_enabled ⇒ Object
98 99 100 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 98 def assert_enabled nil end |
#assert_exists ⇒ Object
Ensure that the element exists by always relocating it Required to trigger waitForAngular. Caching the element here will break the Protractor sync feature so this must be @element = locate.
90 91 92 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 90 def assert_exists @element = locate end |
#assert_not_stale ⇒ Object
94 95 96 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 94 def assert_not_stale nil end |
#clear ⇒ Object
Watir doesn’t define a clear method on element so we have to provide one.
121 122 123 124 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 121 def clear assert_exists element_call { @element.clear } end |
#element_call ⇒ Object
Always raise on stale element ref error. Prevents infinite retry loop.
60 61 62 63 64 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 60 def element_call yield rescue Selenium::WebDriver::Error::StaleElementReferenceError raise end |
#evaluate(expression) ⇒ Object
Evaluate an Angular expression as if it were on the scope of the current element.
132 133 134 135 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 132 def evaluate expression assert_exists driver.protractor.evaluate @element, expression end |
#locate ⇒ Object
avoid context lookup
109 110 111 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 109 def locate locator_class.new(@parent.wd, @selector, self.class.attribute_list).locate end |
#locator ⇒ Object
Return original selector. Method added for protractor compatibility
104 105 106 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 104 def locator @selector end |
#present? ⇒ Boolean
Returns true if the element exists and is visible on the page.
rescue element not found
145 146 147 148 149 150 151 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 145 def present? exists? && visible? rescue Selenium::WebDriver::Error::NoSuchElementError, Selenium::WebDriver::Error::StaleElementReferenceError, UnknownObjectException # if the element disappears between the exists? and visible? calls, # consider it not present. false end |
#selected? ⇒ Boolean
66 67 68 69 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 66 def selected? assert_exists element_call { @element.selected? } end |
#to_json(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
required for watir otherwise execute_script will fail
e = browser.element(tag_name: ‘div’) driver.execute_script ‘return arguments.tagName’, e arguments.tagName“,”args“:}
Convert to a WebElement JSON Object for transmission over the wire.
82 83 84 85 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 82 def to_json(*args) assert_exists { ELEMENT: @element.ref }.to_json end |