I have several written classes that define how I want to handle several websites, with similar methods in both (e.g. login, refresh). Each class opens its own instance of the WATIR browser.
class Site1 def initialize @ie = Watir::Browser.new end def login @ie.goto "www.blah.com" end end
the code sample is basically without threads as follows
require 'watir' require_relative 'site1' agents = [] agents << Site1.new agents.each{ |agent| agent.login }
This works fine, but will not move to the next agent until the current one completes the login. I would like to enable multithreading to handle this, but it doesn't seem to work.
require 'watir' require_relative 'site1' agents = []; threads = [] agents << Site1.new agents.each{ |agent| threads << Thread.new(agent){ agent.login } } threads.each { |t| t.join }
this gives me an error: unknown property or method: navigate . HRESULT error code: 0x8001010e. An application is called an interface that has been configured for another thread.
Does anyone know how to fix this, or how to implement similar functionality?
source share