6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/watir-webdriver/locators/element/selector_builder/css.rb', line 6
def build(selectors)
return unless use_css?(selectors)
if selectors.empty?
css = '*'
else
css = ''
css << (selectors.delete(:tag_name) || '')
klass = selectors.delete(:class)
if klass
if klass.include? ' '
css << %([class="#{css_escape klass}"])
else
css << ".#{klass}"
end
end
href = selectors.delete(:href)
if href
css << %([href~="#{css_escape href}"])
end
selectors.each do |key, value|
key = key.to_s.tr("_", "-")
css << %([#{key}="#{css_escape value}"]) end
end
[:css, css]
end
|