A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.rubydoc.info/github/teamcapybara/capybara/Capybara/Selenium/SafariNode below:

SafariNode – Documentation for teamcapybara/capybara (master) – RubyDoc.info

Class: Capybara::Selenium::SafariNode Constant Summary Constants included from Node::WhitespaceNormalizer

Node::WhitespaceNormalizer::BREAKING_SPACES, Node::WhitespaceNormalizer::EMPTY_LINES, Node::WhitespaceNormalizer::LEADING_SPACES, Node::WhitespaceNormalizer::LEFT_TO_RIGHT_MARK, Node::WhitespaceNormalizer::LINE_SEPERATOR, Node::WhitespaceNormalizer::NON_BREAKING_SPACE, Node::WhitespaceNormalizer::PARAGRAPH_SEPERATOR, Node::WhitespaceNormalizer::REMOVED_CHARACTERS, Node::WhitespaceNormalizer::RIGHT_TO_LEFT_MARK, Node::WhitespaceNormalizer::SQUEEZED_SPACES, Node::WhitespaceNormalizer::TRAILING_SPACES, Node::WhitespaceNormalizer::ZERO_WIDTH_SPACE

Instance Attribute Summary Attributes inherited from Driver::Node

#driver, #initial_cache, #native

Instance Method Summary collapse Methods inherited from Node

#[], #all_text, #content_editable?, #double_click, #drag_to, #drop, #multiple?, #obscured?, #path, #readonly?, #rect, #right_click, #selected?, #set, #shadow_root, #style, #tag_name, #value, #visible?

Methods included from Scroll

#scroll_by, #scroll_to

Methods included from Find

#find_css, #find_xpath

Methods included from Node::WhitespaceNormalizer

#normalize_spacing, #normalize_visible_spacing

Methods inherited from Driver::Node

#==, #[], #all_text, #checked?, #double_click, #drag_to, #drop, #initialize, #inspect, #multiple?, #obscured?, #path, #readonly?, #rect, #right_click, #scroll_by, #scroll_to, #selected?, #set, #shadow_root, #style, #tag_name, #trigger, #value, #visible?

Instance Method Details #click(keys = [], **options) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 9

def click(keys = [], **options)
  
  super
rescue ::Selenium::WebDriver::Error::ElementNotInteractableError
  if tag_name == 'tr'
    warn 'You are attempting to click a table row which has issues in safaridriver - ' \
         'Your test should probably be clicking on a table cell like a user would. ' \
         'Clicking the first cell in the row instead.'
    return find_css('th:first-child,td:first-child')[0].click(keys, **options)
  end
  raise
rescue ::Selenium::WebDriver::Error::WebDriverError => e
  raise unless e.instance_of? ::Selenium::WebDriver::Error::WebDriverError

  
  raise ::Selenium::WebDriver::Error::ElementNotInteractableError,
        'Non distinct error raised in #click, translated to ElementNotInteractableError for retry'
end
#disabled? ⇒ Boolean
53
54
55
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 53

def disabled?
  driver.evaluate_script("arguments[0].matches(':disabled, select:disabled *')", self)
end
#hover ⇒ Object
86
87
88
89
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 86

def hover
  
  scroll_if_needed { browser_action.move_to(native, 0, 0).move_to(native).perform }
end
#select_option ⇒ Object
28
29
30
31
32
33
34
35
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 28

def select_option
  
  selected_or_disabled = driver.execute_script("    arguments[0].closest('select').scrollIntoView();\n    return arguments[0].matches(':disabled, select:disabled *, :checked');\n  JS\n  click unless selected_or_disabled\nend\n", self)
#send_keys(*args) ⇒ Object
63
64
65
66
67
68
69
70
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 63

def send_keys(*args)
  if args.none? { |arg| arg.is_a?(Array) || (arg.is_a?(Symbol) && MODIFIER_KEYS.include?(arg)) }
    return super(*args.map { |arg| arg == :space ? ' ' : arg })
  end

  native.click
  _send_keys(args).perform
end
#set_file(value) ⇒ Object

rubocop:disable Naming/AccessorMethodName

57
58
59
60
61
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 57

def set_file(value) 
  
  native.clear if multiple? && driver.evaluate_script('arguments[0].files', self).any?
  super
end
#set_text(value, clear: nil, **_unused) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 72

def set_text(value, clear: nil, **_unused)
  value = value.to_s
  if clear == :backspace
    
    backspaces = [:backspace] * self.value.to_s.length
    send_keys([:control, 'e'], *backspaces, value)
  else
    super.tap do
      
      send_keys(:space, :backspace) if value.to_s.empty? && clear.nil?
    end
  end
end
#unselect_option ⇒ Object
37
38
39
40
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 37

def unselect_option
  driver.execute_script("arguments[0].closest('select').scrollIntoView()", self)
  super
end
#visible_text ⇒ Object
42
43
44
45
46
47
48
49
50
51
# File 'lib/capybara/selenium/nodes/safari_node.rb', line 42

def visible_text
  return '' unless visible?

  vis_text = driver.execute_script('return arguments[0].innerText', self)
  vis_text.squeeze(' ')
          .gsub(/[\ \n]*\n[\ \n]*/, "\n")
          .gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
          .gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
          .tr("\u00a0", ' ')
end

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4