Multithreading watir/testcase

50 views
Skip to first unread message

Alberto Magalhães

unread,
Mar 7, 2008, 3:57:12 AM3/7/08
to Watir General
Hi all,

I'm trying to execute my testcases in a multithreading environment to
get them executed in concurrency.

For some reason that i don't understand, i get only one ie window
open.

thanks in advance
Below the code that I'm using:

require 'rubygems'
require 'watir'
include Watir

class My_load_test
def load_test
require 'test_new_TESTCASE'
end
end
threads = []
4.times do |i|
threads[i] = Thread.new do
my_load_test = My_load_test.new(data_log, "user_cred")
my_load_test.load_test
end
end
threads.each { |t| t.join }

Željko Filipin

unread,
Mar 7, 2008, 4:08:37 AM3/7/08
to watir-...@googlegroups.com
Hi Alberto,

Did you look at the unit tests? I think there is an example.

Željko
--
ZeljkoFilipin.com

Alberto Magalhães

unread,
Mar 7, 2008, 4:19:27 AM3/7/08
to Watir General
Yes i look.
There is a all_tests.rb, that runs all rb files (sequential).

AM

Željko Filipin

unread,
Mar 7, 2008, 4:23:43 AM3/7/08
to watir-...@googlegroups.com
I think there is concurrent_tests.rb or something like that.

Željko

Željko Filipin

unread,
Mar 7, 2008, 4:25:09 AM3/7/08
to watir-...@googlegroups.com

Alberto Magalhães

unread,
Mar 7, 2008, 4:30:56 AM3/7/08
to Watir General
Yes, there is a concurrent_search.rb.

It works well.

Below, a simple example that doesn't work.

Its open 3 ie windows with the url:http://myserver/Login_input.action.

Only one has the privilege to login. I don't why!!!

thanks

require 'rubygems'
require 'watir'
require 'thread'
include Watir
def load_test
empresa="7692204"
autorizado="2742063"
pwd="123123"
$ie = IE.new
$ie.goto("http://myserver/Login_input.action")
$ie.text_field(:id,"credentials.GROUP_ID").value = empresa
$ie.text_field(:id,"credentials.USER_NAME").value = autorizado
$ie.text_field(:id,"credentials.ACCESS_CODE").value = pwd
$ie.form(:name, "Login_execute").submit
end
threads = []
3.times do
threads << Thread.new {load_test}
end
threads.each {|x| x.join}


On Mar 7, 9:25 am, "Željko Filipin" <zeljko.fili...@gmail.com> wrote:
> Found it.
>
> http://svn.openqa.org/svn/watir/trunk/watir/unittests/other/all_tests...
>
> Željko

Paul Rogers

unread,
Mar 7, 2008, 11:56:57 AM3/7/08
to watir-...@googlegroups.com
if you run the load_test method concurrently, all your threads are
using the $ie global
change it to be @ie and it might work

Paul

John Fitisoff

unread,
Mar 7, 2008, 12:21:26 PM3/7/08
to watir-...@googlegroups.com
How does your application behave once you are logged
in? If you launch a second browser and go to the login
URL, does the login page get displayed or do you get
some landing page instead because you are already
logged in?

For each browser you're launching, it looks like
you're re-entering the user name and password. When I
was first trying to run multiple instances I was
running into the problem described above and it looks
like this might be the same thing that's happening to
you. The first thread will handle the login and
subsequent threads will fail if the user and pword
fields can't be found because some landing page is
displayed instead of the login page. It sounds obvious
but it's not easy to see if you have multiple browser
windows popping up all at once - and the first few
instances may actually look OK because of timing.

You may just need to add an if statement if that's the
case.

Same thing can happen with logout. If one thread logs
out then the other threads are immediately affected
(because the session that all of the threads have been
using was terminated).


--- Alberto Magalh�es <aacmag...@gmail.com>
wrote:

> On Mar 7, 9:25�am, "�eljko Filipin"

> > �eljko
>
>
>

____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

Reply all
Reply to author
Forward
0 new messages