-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdiv.rb
More file actions
33 lines (28 loc) · 697 Bytes
/
div.rb
File metadata and controls
33 lines (28 loc) · 697 Bytes
1
2
3
4
5
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
require "watir-webdriver"
browser = Watir::Browser.new :firefox
folder = Dir.pwd
browser.goto "file://#{folder}/div.html"
require "benchmark"
require "nokogiri"
Benchmark.bm do |x|
x.report("nokogiri") do
Nokogiri::HTML(browser.html).css("div[id ^= 'id']").each do |div|
if div["id"] == "id999"
css = div.css_path
browser.element(css: css).wd.location_once_scrolled_into_view
browser.element(css: css).flash
end
end
end
end
Benchmark.bm do |x|
x.report("watir") do
browser.divs(id: /^id/).each do |div|
if div.id == "id999"
div.wd.location_once_scrolled_into_view
div.flash
end
end
end
end
browser.close