Class: Watir::JavaScripter
Overview
Instance Method Summary
collapse
Instance Method Details
#find_cell(cell) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/safariwatir/scripter.rb', line 42
def find_cell(cell)
return %|getElementById('#{cell.what}')| if cell.how == :id
raise RuntimeError, "Unable to use #{cell.how} to find TableCell" unless cell.row
finder =
case cell.row.how
when :id
%|getElementById('#{cell.row.what}')|
when :index
case cell.row.table.how
when :id
%|getElementById('#{cell.row.table.what}').rows[#{cell.row.what-1}]|
when :index
%|getElementsByTagName('TABLE')[#{cell.row.table.what-1}].rows[#{cell.row.what-1}]|
else
raise MissingWayOfFindingObjectException, "Table element does not support #{cell.row.table.how}"
end
else
raise MissingWayOfFindingObjectException, "TableRow element does not support #{cell.row.how}"
end
finder + %|.cells[#{cell.what-1}]|
end
|
#operate(locator, operation) ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/safariwatir/scripter.rb', line 20
def operate(locator, operation)
%|#{locator}
if (element) {
#{operation}
} else {
return '#{ELEMENT_NOT_FOUND}';
}|
end
|
#wrap(script) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/safariwatir/scripter.rb', line 29
def wrap(script)
script.gsub! "DOCUMENT", "document"
%|#{JS_LIBRARY}
(function() {
#{script}
})()|
end
|