[Wtr-general] Using watir to control JavaScript popups
I am new to watir and I am currently trying to automate some tests, however I am having difficulties automating a _javascript_ popup. This popup asks the user to confirm that they would like to log off, it has two options which are OK and Cancel. After reading some information from various web pages it would appear that this is a difficult thing to do... Any suggestions how to do this? Garry West Trainee Test Analyst InPS Visit our Web site at www.inps.co.uk The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of In Practice Systems Limited or any of its affiliates. If you are not the intended recipient please contact [EMAIL PROTECTED] P please don't print this e-mail unless you really need to. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Using watir to control JavaScript popups
On 13/11/06, Garry West [EMAIL PROTECTED] wrote: I am new to watir and I am currently trying to automate some tests, however I am having difficulties automating a JavaScript popup. This popup asks the user to confirm that they would like to log off, it has two options which are OK and Cancel. After reading some information from various web pages it would appear that this is a difficult thing to do... Any suggestions how to do this? Garry West Hi Garry, Good to see another UK person using Watir (I'm in Brighton). Reliability used to be a problem but I'm now using Watir to test a web app that has loads of JavaScript pop-ups. The method described below is an unofficial add-on rather than a supported part of Watir but it works fine. Get the latest development version of Watir (1127 as of a few moments ago). Then use the following code... # The next line goes with the other require statements at the top of your script require 'watir/contrib/enabled_popup' ... # The next statement clicks the link or button that produces your pop-up - amend it as appropriate. ie.link(:text, yourlink).click_no_wait # Now comes the code that handles the pop-up. No need to change it unless you want to click the 'Cancel' button rather than OK hwnd = ie.enabled_popup(5) # get a handle if one exists if (hwnd) # yes there is a popup w = WinClicker.new w.makeWindowActive(hwnd) # OK or whatever the name on the button is w.clickWindowsButton_hwnd(hwnd, OK) end If you have problems post again or email me. George ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Using watir to control JavaScript popups
Which version of Watir are you using? --Mark From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Garry West Sent: Monday, November 13, 2006 5:04 AM To: wtr-general@rubyforge.org Subject: [Wtr-general] Using watir to control _javascript_ popups I am new to watir and I am currently trying to automate some tests, however I am having difficulties automating a _javascript_ popup. This popup asks the user to confirm that they would like to log off, it has two options which are OK and Cancel. After reading some information from various web pages it would appear that this is a difficult thing to do... Any suggestions how to do this? Garry West Trainee Test Analyst InPS Visit our Web site at www.inps.co.uk The information in this internet email is confidential and is intended solely for the addressee. Access, copying or re-use of information in it by anyone else is not authorised. Any views or opinions presented are solely those of the author and do not necessarily represent those of In Practice Systems Limited or any of its affiliates. If you are not the intended recipient please contact [EMAIL PROTECTED] P please don't print this e-mail unless you really need to. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
At the end I decided to use Watir only. I took a closer look at application that I test and found out that there are labels for elements.input id=ctl00_subContent_userNameInput type=text label for="" id=ctl00_subContent_Label1Username/labelI added this to the end of Watir::TextField#setwhat = @container.label(:for, @what).text puts - at text field '#{what}' enter '[#{what}]'and got - at text field 'Username' enter '[Username]'That is all I need. I added something similar to other methods. I have two questions. 1) Should I use @container or some other variable? It works.2) How should I extract this? I do not want to modify watir.rb, because I would have to modify it every time I upgrade. At the moment I created new file howto.rb (at the end of e-mail). I require this file in my scripts. This is the only way I knew how to override Watir's methods. Is there a better way?Thanks,Zeljko-- http://zeljkofilipin.com/#howto.rbmodule Watir class TextField InputElement def set(setThis) assert_enabled assert_not_readonly highlight(:set) @o.scrollIntoView @o.focus @o.select @o.fireEvent(onSelect) @o.value = @o.fireEvent(onKeyPress) doKeyPress(setThis) highlight(:clear) @o.fireEvent(onChange) @o.fireEvent(onBlur) what = @container.label(:for, @what).text $howto.puts +at text field '#{what}' enter '[#{what}]' end endend ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Grouping Test Cases
I figured this out...after a colleague pointed me at Andy Sipe's blog: http://zbarzone.blogspot.com/2006/04/getting-xml-test-results-from-rails _06.html the relevant code I needed to add: require 'test/unit/collector/objectspace' #replace class def for the suite with one line suite = Test::Unit::Collector::ObjectSpace.new().collect() #generate the output Test::Unit::UI::Reporter.run(suite, 'C:/TestOutput/Sample') Thanks to Andy! -Dara -Original Message- From: Lillis, Dara Sent: Monday, November 13, 2006 2:01 PM To: 'wtr-general@rubyforge.org' Subject: RE: [Wtr-general] Grouping Test Cases [resurrecting an old thread] the code Chris supplies below is useful in that I can use it to run all tests in a given directory. I've been struggling with how to package these tests into suites so I can produce output with Test::Unit::Reporter That is, I want to replace code like this with something more general: require 'test/unit/ui/console/testrunner' require 'test/unit/ui/reporter' require 'TC_TestCase' class TS_Suite def self.suite suite = Test::Unit::TestSuite.new('A Test Suite') suite TC_TestCase.suite return suite end end Test::Unit::UI::Reporter.run(TS_Suite, 'C:/TestOutput/Sample') Any ideas? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris McMahon Sent: Wednesday, May 24, 2006 12:51 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] Grouping Test Cases On 5/24/06, Adrian Rutter [EMAIL PROTECTED] wrote: Could anyone tell me how they are grouping test cases and running suites within Watir? #run_suite.rb topdir = File.join(File.dirname(__FILE__)) Dir.chdir topdir do tests = Dir[test*] tests.each{|x| require x} end ___ 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] Finding the size of IE
Hello,I'm attempting to use watir to check for _javascript_ memory leaks. But I can't find a way to check the memory usage of IE though watir. Is there any way to do this?Thanks.Rob ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] WIN32OLERuntimeError - I get this error after two hours - see details
Hi bb_tester. You have a very good point. As of right now, the test is always running on my personal development machine, though we are already working on building a spider/bot environment. This will minimize the possibility that another process is taking over or killing our process, but I haven't ruled out that possibility yet. Currently my Spider is a scheduled task, which runs every evening after I leave work. If I happen to know I'll be working later, then I reschedule the Spider to run at a different time. Because I am running it on my personal development machine, I try and close as many programs as I don't need before I leave for the day, including popup blockers, IM, Email, and various quick launchers I have running on my system. The only system tray programs I leave running are my antivirus, VPN, and sound controls. None of these systems should affect the way such a program as a Spider performs, but it may be possible. As of yet I haven't decided to coll ect perfomance stats. As I watch my little Spider program run I don't usually see anything out of the ordinary, except for example, when the page I am on contains several hundred images and I am checking each image. One page of ours contains over 1,000 separate images, and during the time it is checking those images there is much higher CPU usage (upwards of 100%). This doesn't really concern me though, because all I am doing is querying the RPC server (Internet Explorer) to find out each image's file size. I have seen IE use 100% CPU and 400,000 KB of Memory and not give me any trouble, though they may signify some kind of memory leak in our web application. I described this somewhat in another thread, where I mentioned our website having a problem at one time, where a certain section of our website would crash IE after a few clicks. This was caused by a line of CSS not being released by IE, and building up memory usage, which was a leak in our software (the ASPX web app we created) and not Internet Explorer. I am convinced, though clumsy it may be, that IE is very robust and can handle anything it's built for, so web app and web site developers need to be very careful to do things the right way. This may be the reason IE is closing on me. I plan now to run at least one test to include memory data from task manager - I have written an external, low-level screenshot program using C#.Net to take the place of the clumsier, less reliable method that Watir 1.4 uses - sending keystrokes and using Paint to save the file -, and it allows me to take a screenshot of either just my browser or the whole screen. For now I believe this will be sufficient. Thank you for your time bb_tester. Nathan - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=5183messageID=14535#14535 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Finding the size of IE
Rob Mayhew wrote: I'm attempting to use watir to check for JavaScript memory leaks. But I can't find a way to check the memory usage of IE though watir. Is there any way to do this? That requires kernel-level programming. Win32 uses virtual memory. As IE runs, no matter what it does, its memory usage variable in your Task Manager's Process's tab will always go up; never down. That's because virtual memory has no need to truly free any allocated memory. If your program stops using that memory, then it will languish in your swapper file while IE uses memory pages that are (hopefully!) swapped into physical memory. Within each program's memory arena are heaps, managed by the system. (These contain the storage used by C language heap functions, malloc() and free(). Programs typically use heaps inside of heaps.) If you got a handle to the IE process, you could query its system heaps, and detect which ones were in-use and which are not. And this still would not directly detect a leak. Etc. etc. etc. You don't want to know what all the ActiveX (COM) does between IE, memory, and Javascript. The simplest way to test for leaks is leave a test case running all night in a loop, and see if it crashes. If I had Purify, I could try Purify - Ruby - IE - JavaScript. Except all of those items probably leak like crazy (except Ruby, of course!), so you would not be able to tell the trees for the forest. -- Phlip http://c2.com/cgi/wiki?ZeekLand -- NOT a blog!! ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general