Created
September 20, 2011 23:50
-
-
Save alisterscott/1230762 to your computer and use it in GitHub Desktop.
simple watir-webdriver threading example for load testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
require 'watir-webdriver' | |
def test_google | |
3.times do | |
browser = Watir::Browser.start 'http://www.etsy.com', :chrome | |
browser.text_field(:name, 'search_query').set 'hat' | |
start_time = Time.now | |
browser.button(:text, 'Search').click | |
end_time = Time.now | |
puts end_time - start_time | |
browser.close | |
end | |
end | |
threads = [] | |
30.times do | |
threads << Thread.new {test_google} | |
end | |
threads.each {|x| x.join} |
My local machine goes out of memory once I try to load 30 browsers at a time. Tried headless also. Haven't had much luck. :(
Thanks for this code !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works great for a maximum of ten concurrent instances. How would you suggest scaling this up to 30-40 concurrent instances??