Class: Capybara::Selenium::EdgeNode
- Inherits:
-
Node
- Object
- Driver::Node
- Node
- Capybara::Selenium::EdgeNode
- Includes:
- Html5Drag
- Defined in:
- lib/capybara/selenium/nodes/edge_node.rb
Instance Attribute Summary
Attributes inherited from Driver::Node
#driver, #initial_cache, #native
Instance Method Summary collapse
-
#disabled? ⇒ Boolean
def click(*) super rescue ::Selenium::WebDriver::Error::WebDriverError => e # chromedriver 74 (at least on mac) raises the wrong error for this raise ::Selenium::WebDriver::Error::ElementClickInterceptedError, e.message if e.message.match?(/element click intercepted/).
- #drop(*args) ⇒ Object
- #select_option ⇒ Object
-
#set_file(value) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #set_text(value, clear: nil, **_unused) ⇒ Object
Methods inherited from Node
#==, #[], #all_text, #click, #content_editable?, #double_click, #drag_to, #hover, #multiple?, #obscured?, #path, #readonly?, #right_click, #selected?, #send_keys, #set, #style, #tag_name, #unselect_option, #value, #visible?, #visible_text
Methods included from Scroll
Methods included from Find
Methods inherited from Driver::Node
#==, #[], #all_text, #checked?, #click, #double_click, #drag_to, #hover, #initialize, #inspect, #multiple?, #obscured?, #path, #readonly?, #right_click, #scroll_by, #scroll_to, #selected?, #send_keys, #set, #style, #tag_name, #trigger, #unselect_option, #value, #visible?, #visible_text
Constructor Details
This class inherits a constructor from Capybara::Driver::Node
Instance Method Details
#disabled? ⇒ Boolean
def click(*) super rescue ::Selenium::WebDriver::Error::WebDriverError => e # chromedriver 74 (at least on mac) raises the wrong error for this raise ::Selenium::WebDriver::Error::ElementClickInterceptedError, e.message if e.message.match?(/element click intercepted/)
raise end
48 49 50 51 52 |
# File 'lib/capybara/selenium/nodes/edge_node.rb', line 48 def disabled? return super unless chrome_edge? driver.evaluate_script("arguments[0].matches(':disabled, select:disabled *')", self) end |
#drop(*args) ⇒ Object
33 34 35 36 37 |
# File 'lib/capybara/selenium/nodes/edge_node.rb', line 33 def drop(*args) return super unless chrome_edge? html5_drop(*args) end |
#select_option ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/capybara/selenium/nodes/edge_node.rb', line 54 def select_option return super unless chrome_edge? # To optimize to only one check and then click selected_or_disabled = driver.evaluate_script(<<~JS, self) arguments[0].matches(':disabled, select:disabled *, :checked') JS click unless selected_or_disabled end |
#set_file(value) ⇒ Object
rubocop:disable Naming/AccessorMethodName
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/capybara/selenium/nodes/edge_node.rb', line 17 def set_file(value) # rubocop:disable Naming/AccessorMethodName # In Chrome 75+ files are appended (due to WebDriver spec - why?) so we have to clear here if its multiple and already set if chrome_edge? driver.execute_script(<<~JS, self) if (arguments[0].multiple && (arguments[0].files.length > 0)){ arguments[0].value = null; } JS end super rescue *file_errors => e raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload" if e..match?(/File not found : .+\n.+/m) raise end |
#set_text(value, clear: nil, **_unused) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/capybara/selenium/nodes/edge_node.rb', line 8 def set_text(value, clear: nil, **_unused) return super unless chrome_edge? super.tap do # React doesn't see the chromedriver element clear send_keys(:space, :backspace) if value.to_s.empty? && clear.nil? end end |