Module: Bermuda::XPath

Extended by:
XPath
Includes:
XPath
Included in:
XPath
Defined in:
lib/bermuda/xpath.rb

Instance Method Summary collapse

Instance Method Details

#accordion_content(title = nil, options = {}) ⇒ Object



36
37
38
# File 'lib/bermuda/xpath.rb', line 36

def accordion_content(title = nil, options = {})
  accordion_header(title, options).next_sibling
end

#accordion_header(title = nil, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bermuda/xpath.rb', line 23

def accordion_header(title = nil, options = {})
  xpath = descendant[attr(:class).includes('ui-accordion-header')]

  if options.key?(:active)
    state = attr(:class).includes('ui-state-active')
    state = ~state unless options[:active]
    xpath = xpath[state]
  end

  xpath = xpath[descendant(:a).text.is title] if title
  xpath
end

#autocompletion(text = nil) ⇒ Object



40
41
42
43
44
45
# File 'lib/bermuda/xpath.rb', line 40

def autocompletion(text = nil)
  xpath = descendant[attr(:class).includes('ui-autocomplete')]
  xpath = xpath.descendant[attr(:class).includes('ui-menu-item')]
  xpath = xpath[descendant(:a).text.is text] if text
  xpath
end

#dialog(title = nil) ⇒ Object



47
48
49
50
51
# File 'lib/bermuda/xpath.rb', line 47

def dialog(title = nil)
  xpath = descendant[attr(:class).includes('ui-dialog')]
  xpath = xpath[descendant[attr(:class).includes('ui-dialog-title')].text.is title] if title
  xpath
end

#progressbar(options = {}) ⇒ Object



53
54
55
56
57
# File 'lib/bermuda/xpath.rb', line 53

def progressbar(options = {})
  xpath = descendant[attr(:class).includes('ui-progressbar')]
  xpath = xpath[attr(:'aria-valuenow') == options[:value]] if options[:value]
  xpath
end

#tab_content(title = nil, options = {}) ⇒ Object



72
73
74
# File 'lib/bermuda/xpath.rb', line 72

def tab_content(title = nil, options = {})
  descendant[Expression::Literal.new("concat('#', @id)") == anywhere(tab_header(title, options)).descendant(:a).attr(:href)]
end

#tab_header(title = nil, options = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/bermuda/xpath.rb', line 59

def tab_header(title = nil, options = {})
  xpath = descendant[attr(:class).includes('ui-tabs-nav')].child

  if options.key?(:active)
    state = attr(:class).includes('ui-state-active')
    state = ~state unless options[:active]
    xpath = xpath[state]
  end

  xpath = xpath[descendant(:a).text.is title] if title
  xpath
end