-
Notifications
You must be signed in to change notification settings - Fork 20
/
Rakefile
42 lines (33 loc) · 1.32 KB
/
Rakefile
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
34
35
36
37
38
39
40
41
42
require 'parallel'
require 'selenium/webdriver'
task :benchmark do
browsers = [
{ platform: "OS X 10.11", browserName: "Chrome", version: "53" },
{ platform: "OS X 10.11", browserName: "Chrome", version: "52" },
{ platform: "OS X 10.11", browserName: "Firefox", version: "48" },
{ platform: "OS X 10.11", browserName: "Firefox", version: "47" },
]
url = "http://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub"
cname = File.open('CNAME').read
benchmark = (ENV['BENCHMARK'] || '_benchmarks/*.md').split(',')
Dir.glob(benchmark).each do |filename|
puts "Benchmarking #{filename}"
Parallel.each(browsers, in_threads: 5) do |caps|
driver = Selenium::WebDriver.for(:remote, url: url, desired_capabilities: caps)
driver.get('http://' + cname.strip + '/' + File.basename(filename, ".md"))
wait = Selenium::WebDriver::Wait.new(:timeout => 60)
wait.until do
button = driver.find_element(:tag_name, 'button')
button
end
button = driver.find_element(:tag_name, 'button')
button.click
wait = Selenium::WebDriver::Wait.new(:timeout => 600)
wait.until do
button = driver.find_element(:tag_name, 'button')
button unless button.attribute('disabled')
end
driver.quit
end
end
end