Class: Watir::ElementLocator
- Inherits:
-
Object
- Object
- Watir::ElementLocator
- Defined in:
- lib/angular_webdriver/protractor/watir_patch.rb
Instance Method Summary collapse
-
#locate ⇒ Object
always raise element not found / stale reference error.
- #validate_element(element) ⇒ Object
Instance Method Details
#locate ⇒ Object
always raise element not found / stale reference error
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 186 def locate # element.all(by.partialButtonText('text')).to_a[0].value creates the # selector {:element=>#<Selenium::WebDriver::Element ...>} # in that case we've already located the element. # # see 'should find multiple buttons containing "text"' in locators_spec.rb return @selector[:element] if @selector.is_a?(Hash) && @selector[:element].is_a?(Selenium::WebDriver::Element) e = by_id and return e # short-circuit if :id is given if @selector.size == 1 element = find_first_by_one else element = find_first_by_multiple end # This actually only applies when finding by xpath/css - browser.text_field(:xpath, "//input[@type='radio']") # We don't need to validate the element if we built the xpath ourselves. # It is also used to alter behavior of methods locating more than one type of element # (e.g. text_field locates both input and textarea) validate_element(element) if element end |
#validate_element(element) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/angular_webdriver/protractor/watir_patch.rb', line 171 def validate_element(element) tn = @selector[:tag_name] return element unless tn # don't validate nil tag names element_tag_name = element.tag_name.downcase return if tn && !tag_name_matches?(element_tag_name, tn) if element_tag_name == 'input' return if @selector[:type] && @selector[:type] != element.attribute(:type) end element end |