[Wtr-general] Multithreading login access through multiple browsers using Watir
Hi all, I have a Watir 1.4.1 script driving a performance test against one of my servers, and wanted to multithread it to allow multiple browsers to run against the server from the same client machine. I have a data file 'user.dat' containing username and password information that I read in and then insert into the appropriate text fields on the start up page. I have a synchronization block around the access to the username password information as well as one around where the information is placed into the text_fields. When I run this script I see the following behavior, I do not get logins occuring consistantly, usually with a complaint that the username/password information is incorrect. When I printed out the username and passwords that were being used it looked as if the synchronized block was not being honored. The console out put from the code below is username: SMYTH1230 password: SMYTH1230 username: SMYTH2367 password: SMYTH2367 username: SMYTH2394 password: SMYTH2394 SMYTH1230 SMYTH2394 SMYTH2367 The user name and password are correct BUT there was a context switch within the synchronized block which switched the password before the block was completed. I would have expected to see username: SMYTH1230 password: SMYTH1230 SMYTH1230 username: SMYTH2367 password: SMYTH2367 SMYTH2367 username: SMYTH2394 password: SMYTH2394 SMYTH2394 Can someone help me with the source of this problem, is this a problem with Watir or in my use of synchronization within Ruby? I appreciate any help you can give me. Program: require 'monitor' require 'watir' require 'logger' include Watir class User_credentials include MonitorMixin def initialize(user_file) @file = File.new(user_file, 'r') super() end def get_credentials synchronize { line = @file.gets @credentials = Hash.new @credentials['username'], @credentials['password'], @credentials['index'] = line.split(',') return @credentials } end end def think (enabled, time) if enabled : sleep time end end class My_load_test include MonitorMixin def initialize(log, user_info) @log = log @user_info = user_info super() end def load_test sleep_enabled = true standard_thinktime = 1 server_name = myserver.ibm.com/loginPage' # Get a browser instance ie=IE.new for i in 1..3 # Go to the default Portal page ie.goto(server_name) @log.info("Go to #{server_name}, #{ie.down_load_time}") # Enter username and password and login username = '' synchronize do user_credential = @user_info.get_credentials username = user_credential['username'] ie.textField(:id, 'userID').set(username) puts "username: #{username} password: #{user_credential['password']}" ie.textField(:id, 'password').set(user_credential['password']) puts user_credential['password'] end ie.button(:value, 'Log in').click @log.info("#{username}, Login , #{ie.down_load_time}") end # Logout ie.link(:text, 'Log Out').click @log.info("#{username}, Logout, #{ie.down_load_time}") end ie.close end end threads = [] user_cred = User_credentials.new('user.dat') data_log = Logger.new('datalog.log', 5, 10 *1024*1024) 3.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 } Thanks, Scott Snyder Senior Performance Analyst IBM Corporation "The supreme misfortune is when theory outstrips performance." "There are three classes of people. Those who see; those who see when they are shown; those who do not see." - Leonardo da Vinci ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Navigating in IE frames
Lonny asked: > Along that line, can anyone answer this for me? A frame object MUST have a > URL, or the > frame will be blank. Does anyone know how I can pull that property out of the > frame? That is, > something like frame(:name, 'my_frame').url, which would return a url or nil? Try this... frame(:name, 'my_frame').document.url ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Navigating in IE frames
If you have a web page (ie object named @ie let's say), containing a frame, which contains another frame, which contains your element, you would do: @ie.frame(:id, 'frame1').frame(:id, 'frame2').ECMTestFixture.text_field(:name, "inpListFilter" ).set("adm" ) Of course you can use name or whatever rather than id. Along that line, can anyone answer this for me? A frame object MUST have a URL, or the frame will be blank. Does anyone know how I can pull that property out of the frame? That is, something like frame(:name, 'my_frame').url, which would return a url or nil? I am aware that there is not a url method for frames within Watir. But does anyone know how I can code one? Lonny Eachus == Subject: [Wtr-general] Navigating in IE frames From: Dave Munns <[EMAIL PROTECTED]> Date: Thu, 10 Aug 2006 12:17:59 CDT Hi. I am building a test tool to automate navigation through a UI with IE frames. Text fields, buttons, lists, and web dialog boxes are all targets for my tool. The examples I see in the watir user guide don't mention frames. I have tried navigating to a text field, using the user guide example, but watir complains that my text field identifier ("inpListFilter") is not found (I identified it with SpySmith). Do I have to qualify the identifier with a frame name or set the frame context ? Here is the offending line: ECMTestFixture.text_field(:name, "inpListFilter" ).set("adm" ) ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Navigating in IE frames
Yes, you do need to specify the frame. Try something like: ie.frame('FrameName').text_field(:name, "inpListFilter" ).set("adm" )You should be able to incorporate the FrameName into your 'ECMTestFixture' object. To see the frames that Ruby/Watir sees, try the following at an IRB prompt:> ie.show_framesOn 10/08/06, Dave Munns < [EMAIL PROTECTED]> wrote:Hi. I am building a test tool to automate navigation through a UI with IE frames. Text fields, buttons, lists, and web dialog boxes are all targets for my tool. The examples I see in the watir user guide don't mention frames. I have tried navigating to a text field, using the user guide example, but watir complains that my text field identifier ("inpListFilter") is not found (I identified it with SpySmith). Do I have to qualify the identifier with a frame name or set the frame context ? Here is the offending line:ECMTestFixture.text_field(:name, "inpListFilter" ).set("adm" ) ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Navigating in IE frames
Hi. I am building a test tool to automate navigation through a UI with IE frames. Text fields, buttons, lists, and web dialog boxes are all targets for my tool. The examples I see in the watir user guide don't mention frames. I have tried navigating to a text field, using the user guide example, but watir complains that my text field identifier ("inpListFilter") is not found (I identified it with SpySmith). Do I have to qualify the identifier with a frame name or set the frame context ? Here is the offending line: ECMTestFixture.text_field(:name, "inpListFilter" ).set("adm" ) - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3459&messageID=9657#9657 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Clicking on the java script dialog box when IE window is not in focus
Yes, I too would be interested in the answers to some of those questions, as well as any relevant facts Manish has already uncovered in that area. This is very relevant to some of the things we have been doing. Lonny Eachus == Subject: [Wtr-general] Clicking on the _javascript_ dialog box when IE window is not in focus From: Manish Sapariya <[EMAIL PROTECTED]> Date: Thu, 10 Aug 2006 18:14:10 +0530 Hi, Last few days I have been investigating this and tried all the dialog related tests in the current watir (1.5) code. None of the test I tried works if the IE windows is not in focus. . . . ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Writing the output of show all objects to a file
This is where Ruby shines. You will probably need to extend Watir, but that is easy enough. Here is show_all_objects from watir.rb: -- def show_all_objects puts "---Objects in page -" doc = document s = "" props = ["name", "id", "value", "alt", "src"] doc.all.each do |n| begin s += n.invoke("type").to_s.ljust(16) rescue next end props.each do |prop| begin p = n.invoke(prop) s += " " + "#{prop}=#{p}".to_s.ljust(18) rescue # this object probably doesnt have this property end end s += "\n" end puts s end -- You can see that it explicitly uses "puts" to print to stdout. Instead, what you probably want is a string. That could hardly be simpler. All you need to do is replace the second-to-last line ("puts s") with just "s". That will return the string rather than printing it. So, just do this in your code: class Watir::IE def get_all_objects < body of code from above (between the "def" and "end" lines) goes here > end end Then replace the "puts s" with "s" in that method, and you now have a new Watir method. If your IE object is called @ie, you can do: my_objects_string = @ie.get_all_objects As a side note, it appears to me that the show_all_objects method really belongs within "Container" rather than "IE", but that is a separate matter. Lonny Eachus == Subject: Re: [Wtr-general] Writing the output of show all objects to a file From: SRK <[EMAIL PROTECTED]> Date: Wed, 9 Aug 2006 18:13:35 +0100 (BST) Thanks, but the in the text file only the value "nil" is recorded and the objects are not getting recorded. Nandan <[EMAIL PROTECTED]> wrote: Is this what you mean? outp = File.open("out.txt", "w") sr = ie.show_all_objects outp.puts sr outp.close - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3375&messageID=9406#9406 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to use for loop in watir script?
>My requirement is that, I want to print some text in 5 times in one text box like "User name". I want to do with for loops but I'm not able do that. Give me suggestion if you have any sense about that require 'watir' include Watir ie = IE.start("http://www.google.ca";) the_field = ie.text_field(:index, 1) message = "Please ask nicely next time " * 5 the_field.set(message) ---Michael B. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to use for loop in watir script?
Well, you can do something like:st = ""5.times do |x| st << "Joe" + x.to_sendie.text_field(:name, 'username').set(st)Results is the text_field called username being set to "Joe0Joe1Joe2Joe3Joe4" Hope that gives you some direction.Rand.On 8/10/06, Mayank <[EMAIL PROTECTED] > wrote:My requirement is that, I want to print some text in 5 times in one text box like "User name". I want to do with for loops but I'm not able do that. Give me suggestion if you have any sense about that -Posted via Jive Forumshttp://forums.openqa.org/thread.jspa?threadID=3436&messageID=9610#9610 ___Wtr-general mailing listWtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general-- "I am the most humble person in the world!" ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to use for loop in watir script?
I'm not sure I understand your requirement or why you can't do a for loop, here's a quick stab in the dark: ie.text_field(:name, 'user name').set('name' * 5)More information about your situation may get a different and possibly better answer. -CharleyOn 8/10/06, Mayank <[EMAIL PROTECTED]> wrote: My requirement is that, I want to print some text in 5 times in one text box like "User name". I want to do with for loops but I'm not able do that. Give me suggestion if you have any sense about that- Posted via Jive Forumshttp://forums.openqa.org/thread.jspa?threadID=3436&messageID=9610#9610___ Wtr-general mailing listWtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] ie.back
Hey Aidy, The back method does a straight call to ie's GoBack method, and according to the comments throws that exception only if for some reason it can't go back. If it is going back then you might want to swallow the exception and add an assert for an element on the page that you hoped to go back to. I don't see any inherent reason why it's throwing the exception, but that's just from a quick look. -CharleyOn 8/10/06, Adrian Lewis <[EMAIL PROTECTED]> wrote: HI, The version of watir is shown in the err msg below. The browser isdefinitely going back to the previous HTML page, yet I receive this exception: c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1054 /./watir.rb:1500:in`method_missing': GoBack (WIN32OLERuntimeError) Should I catch the exception or choose a different method? (sorry if this has been briefed, but I cannot access the internet at the moment) Cheers Aidy---This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system.If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. ---___Wtr-general mailing list Wtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to use for loop in watir script?
On 8/9/06, Mayank <[EMAIL PROTECTED]> wrote: > My requirement is that, I want to print some text in 5 times in one text box > like "User name". I want to do with for loops but I'm not able do that. Give > me suggestion if you have any sense about that C:\ruby\doc\ProgrammingRuby.chm ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Clicking on the java script dialog box when IE window is not in focus
Hi Manish Yes. I am interested in that code. Right now I am struck at the Javascript dialog box. I also tried with various combinations but couldnt succeed. Thanks Meghanath -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Manish Sapariya Sent: Thursday, August 10, 2006 8:44 AM To: wtr-general@rubyforge.org Subject: [Wtr-general] Clicking on the java script dialog box when IE window is not in focus Hi, Last few days I have been investigating this and tried all the dialog related tests in the current watir (1.5) code. None of the test I tried works if the IE windows is not in focus. I started digging about how this could be achieved and I came across few win32 api (getting window handle, sending messages to applications) and I got one proof of concept vb code build, which can click on IE javascript dialog when not in focus. My next task was to put it in ruby using win32 api. When doing this I came across guitest tool in ruby and one of the post by Bret mentioning this tool. He mentioned that guitest needed to compiled in cygwin. Nevertheless I gave it a try and to my surprise using nmake I can make the guitest.so libarary which works like charm. I have rewritten the javascript_test.rb using the *click_no_wait* and the guitest and it works like charm. With guitest library my IE window need not be focus when it needs to click on javascript dialog. While investigating I checked out watir code in more details and came across some things which I cant explain to myself. I would appreciate any clarification. 1. WinClicker has almost the code needed to do what I have done. But I could not find any test which does the clicking when IE window is not focused. Question : What was the basic purpose of writing winclicker? 2. Autoit is used to simulate key strokes? Why does Autoit poses the requirement that the windows that it works on needs to be focused. Can't autoit script work on window that it has handle of? 3. What are other features in watir that we can use guitest to enhance? 4. I could not exactly figure out the need for IEDialog as well. 5. My current implementation works by searching for the window with title "Microsoft Internet Explorer". Ideally I would like to search for child windows of IE, of which I have handle in ie.hwnd. However for some reason windows does not recognize the javascript dialog as the child window of IE. Surprisingly when I try to find the parent window of dialog it is shown correctly IE as the parent window of javascript dialog box? Any ideas? If anybody wants to checkout this code I can send out the instructions to build guitest.so (or can send the binary itself) and other test code that I have. Thanks and Regards, Manish ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] login popup problem
Hello. I have a problem with a login popup window. I can't set a text (username and password) into a login window which appear after entering to a site. I tried to pass it by going directly to url (http://username:[EMAIL PROTECTED]/) but it doesn't work on IE 6.0. I try to do it this way: w = WinClicker.new handle = w.getWindowHandle("title") w.makeWindowActive( handle ) w.setComboBoxText(handle, "login") w.clickWindowsButton_hwnd(handle ,"OK" ) but it is not a good solution. Has anyone solved a similar proble? - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3449&messageID=9635#9635 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] FireWatir performance and watir on linux
Hi, I have proof of concept for clicking on javascript dialog boxes in firefox on linux using at-spi library. However before I proceed ahead with some more experiments, I wanted to investigate the reason of slowness of FireWatir. 1. Is it because of inherent approach of driving firefox using javascript? 2. Is it because of the jssh server plugin? 3. Is it because of the way jssh plugin being used? Has anybody worked on making it faster if not as fast as IE? For me the speed of FireWatir was one of turn off when it comes using it on linux/firefox. Any inputs will be of great help for moving forward. Thanks and Regards, Manish ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] ie.back
HI, The version of watir is shown in the err msg below. The browser is definitely going back to the previous HTML page, yet I receive this exception: c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1054/./watir.rb:1500:in `method_missing': GoBack (WIN32OLERuntimeError) Should I catch the exception or choose a different method? (sorry if this has been briefed, but I cannot access the internet at the moment) Cheers Aidy --- This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. --- ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Clicking on the java script dialog box when IE window is not in focus
Hi, Last few days I have been investigating this and tried all the dialog related tests in the current watir (1.5) code. None of the test I tried works if the IE windows is not in focus. I started digging about how this could be achieved and I came across few win32 api (getting window handle, sending messages to applications) and I got one proof of concept vb code build, which can click on IE javascript dialog when not in focus. My next task was to put it in ruby using win32 api. When doing this I came across guitest tool in ruby and one of the post by Bret mentioning this tool. He mentioned that guitest needed to compiled in cygwin. Nevertheless I gave it a try and to my surprise using nmake I can make the guitest.so libarary which works like charm. I have rewritten the javascript_test.rb using the *click_no_wait* and the guitest and it works like charm. With guitest library my IE window need not be focus when it needs to click on javascript dialog. While investigating I checked out watir code in more details and came across some things which I cant explain to myself. I would appreciate any clarification. 1. WinClicker has almost the code needed to do what I have done. But I could not find any test which does the clicking when IE window is not focused. Question : What was the basic purpose of writing winclicker? 2. Autoit is used to simulate key strokes? Why does Autoit poses the requirement that the windows that it works on needs to be focused. Can't autoit script work on window that it has handle of? 3. What are other features in watir that we can use guitest to enhance? 4. I could not exactly figure out the need for IEDialog as well. 5. My current implementation works by searching for the window with title "Microsoft Internet Explorer". Ideally I would like to search for child windows of IE, of which I have handle in ie.hwnd. However for some reason windows does not recognize the javascript dialog as the child window of IE. Surprisingly when I try to find the parent window of dialog it is shown correctly IE as the parent window of javascript dialog box? Any ideas? If anybody wants to checkout this code I can send out the instructions to build guitest.so (or can send the binary itself) and other test code that I have. Thanks and Regards, Manish ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to check for opened IE windows?
Mark is correct. In the case that he describes, you will need to use 1.5 and do ie.modal_dialog() to attach to it. Bret Cain, Mark wrote: > Do you see this "-- Web Page Dialog" in the title bar of your popup > pages? If yes then you are dealing with a modal web page and you will > NOT be able to attach the normal way using Watir. > > --Mark > > -Original Message- > > Hi, > > I have been trying to create a test for a website. A new window pops out > whenever I choose something from a select list. I cannot take control of > that new window by url nor by title. So I was wondering if there is > another way for Watir to take control of it? And is there a way (a > command) for Watir/Ruby to see all opened IE windows? > ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] How to use for loop in watir script?
My requirement is that, I want to print some text in 5 times in one text box like "User name". I want to do with for loops but I'm not able do that. Give me suggestion if you have any sense about that - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3436&messageID=9610#9610 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general