lib/appium_lib/common/helper.rb in appium_lib-9.5.0 vs lib/appium_lib/common/helper.rb in appium_lib-9.6.0

- old
+ new

@@ -75,13 +75,13 @@ def reset @result = Hash.new 0 end # http://nokogiri.org/Nokogiri/XML/SAX/Document.html - def start_element(name, attrs = []) + def start_element(name, attrs = [], driver = $driver) # Count only visible elements. Android is always visible - element_visible = $driver.device_is_android? ? true : Hash[attrs]['visible'] == 'true' + element_visible = driver.device_is_android? ? true : Hash[attrs]['visible'] == 'true' @result[name] += 1 if element_visible end def formatted_result message = '' @@ -113,12 +113,12 @@ # Converts pixel values to window relative values # # ```ruby # px_to_window_rel x: 50, y: 150 # ``` - def px_to_window_rel(opts = {}) - w = $driver.window_size + def px_to_window_rel(opts = {}, driver = $driver) + w = driver.window_size x = opts.fetch :x, 0 y = opts.fetch :y, 0 OpenStruct.new(x: "#{x.to_f} / #{w.width.to_f}", y: "#{y.to_f} / #{w.height.to_f}") @@ -212,9 +212,10 @@ element = @element_stack.last element[:text] = chars end end + # @private def _no_such_element error_message = 'An element could not be located on the page using the given search parameters.' raise Selenium::WebDriver::Error::NoSuchElementError, error_message end end # module Common