Re: [Wtr-general] UnknownObject Exception when running test cases
I noticed the line: $ie.text_field(:name, Find Account).click Is in both the end of the login method and the beginning of the clickLinks method. Maybe that is throwing off the state that clickLinks expects? Also, maybe check to see if test_clickLinks is running before test_login. If I recall correctly the test_ methods are run in ASCIIbetical order. If that is the case, then try collapsing the two test_ methods into one. On 6/26/07, Tiffany Fodor [EMAIL PROTECTED] wrote: After some tinkering, I think I've figured out my problem. It seems the Test::Unit::TestCase functionality is expecting to open files and run them as test cases rather than calls to methods in other files. I was hoping to get all the data I need from a spreadsheet once, with the harness code, and then pass it to various test case methods rather than getting the data from the spreadsheet in each test case. I think I can work around this, though. ___ 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] Problems with Test::Unit in Eclipse
If you mean the __FILE__ variable, it is a pseudo variable that contains the current source file name. So it will work even when used as the first line of a script. It's really useful in cases like this, where you need to dynamically add dir names to the load path before you try to require other files. On 6/26/07, jim_matt [EMAIL PROTECTED] wrote: Thanks Walter, I think I understand what you are trying to do here. The problem is that it has to open a file first to get the line: $: File.expand_path(File.dirname(__FILE__)) So how do you get it to find that first file? Jim ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Redirection of standard output
watir-check.rb 21 | tee watir-check.tmp I am using Windows XP so this is run in cmd.exe, but it normally works with this syntax. (tee.exe is from gnuwin32.) This did not work, the .tmp file is created but is empty and I see nothing in the console window. Does running the command like this work for you? watir-check.rb | tee console.log I'm using WinXP and Cygwin's tee.exe. If I run scripts in the above fashion, I get the desired behavior - the script output shows up in the cmd.exe window and console.log at the same time. Still the same problem. I tried to simplify even more: ruby watir-check.rb watir-check.tmp To my surprise not even this worked. Odd, this should work. Are you running the command manually in the console window, or is another script/program executing the command? If all else fails, another (more complicated) way to do this is to write a little Ruby script that runs your Watir script using IO.popen, and uses the resulting IO object to read the standard output of the Watir script. The parent script can then do anything it wants with the output; in my case I wrote it to a file. When I tried saving the output of Watir scripts this way, it worked fine (although I've seen complaints about the reliability of Ruby's popen method on win32). But resorting to that shouldn't be necessary; hopefully you can get the tee.exe technique working. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Redirection of standard output
I think I understand what is happening now. It is buffering. I did not notice, since I let the program ran for long time in a loop and interrupted it later (with Control-C). After some googling I inserted STDOUT.flush and this cured the problem. Ah, good call. Another way to cure it might be to disable buffering for $stdout completely, with: $stdout.sync = true ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] how to properly use the snippet function?
When I needed to use that snippet, I just left the whole thing in a separate file, and initiated the cache/cookie cleanup with system('ruby del_cache.rb') You could also probably paste the whole blob of code into a new method and it should work. It would be possible to do the same work in fewer lines of code, but you'd have to refactor the script somewhat. On 6/13/07, reinier [EMAIL PROTECTED] wrote: I am trying to get rid of all cookies via a function. On this forum I found the Snippet thingy. http://rubyforge.org/snippet/detail.php?type=snippetid=26 So I included that code in my script and trying to use it, but I can't figure out how. this is the code: [code] DeleteUrlCacheEntry = Win32API.new(wininet, DeleteUrlCacheEntry, ['P'], 'V') [/code] So what function should be called to delete all the cookies? ___ 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 clear cache from within watir script?
Give the script from this page a try: http://rubyforge.org/snippet/detail.php?type=snippetid=26 For a quick demo just copy/paste the whole thing into a file, name it del_cache.rb, and run it. It always worked fine for me on XP SP2. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
For a quick fix, try adding this to the top of your c:/runner/data/suites/project/test.rb file (before any require statements): $LOAD_PATH.unshift c:/runner/data/suites/ if $0 == __FILE__ That way when test.rb is executed, the suites dir will be added to $LOAD_PATH, and require 'library' will load the c:/runner/data/suites/library.rb file. But the way I usually see this done is to add relative dirs to $LOAD_PATH instead of absolute paths. That way the files you require will still be found even if the directory structure they live in changes. For example, in test.rb you might add at the top: $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ So if test.rb is in c:/runner/data/suites/project, this will find the name of the dir one level up from __FILE__'s dir (c:/runner/data/suites/) and add it to $LOAD_PATH. If all else fails, you might try dropping library.rb into one of the default $LOAD_PATH dirs (even though this isn't a very portable solution). Such as: C:\ruby\lib\ruby\site_ruby\1.8\ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
The way I solved this back when I was using the rails app was: - I put all my library files into a common dir - I added a line of code to each test script that allows it to find and add the lib dir to $LOAD_PATH For this I use the same idiom from some of the Watir unit test files (in this case it will add the dir one up from the top-level script to $LOAD_PATH): $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..') if $0 == __FILE__ So, you might be able to do something like this: 1. In the runner/data dir, create a new dir called 'lib' and copy your library files to it 2. In your test scripts, add the above line of code at the top 3. Then change your require statements to reflect the lib dir: require 'lib/library_file.rb' Aside from testing this using the runner app, you can test the changes manually by cd'ing in a command window to c:\ or some other random dir, then try running your script from there (ruby c:\foo\runner\data\suites\test.rb). ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
The version of the runner app I posted doesn't check to see if a script is already running before it executes a new one. But that would definitely be necessary if more than one person is likely to try to run a Watir script at the same time. Some solutions I considered were to use a lock file, or perhaps add code to verify that no IE processes exist before starting a Watir script. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
I posted my zipped rails app as an attachment on the Watir contributions page: http://wiki.openqa.org/display/WTR/Rails+test+runner+example+app In my haste to reply I lost track of the fact that you already had something similar working, except for the issue with the goto method not working (which is now solved). So what you have may actually be a better solution than this app. :) But for what it's worth, the zipfile I posted should be all you need to see my app working, provided that rails is installed too. Please let me know if there are any questions. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
One bare-bones solution for this problem is to use the Ruby gserver library to start your tests - see the code snippets in this post: http://www.mail-archive.com/wtr-general@rubyforge.org/msg07247.html The idea is to leave a little Ruby script listening on the test client, and when someone sends any traffic to it (a telnet connection, hitting the port with a web browser, etc), your Watir script is executed. It sounds like you're looking for a more full-featured solution, though. For that I'd suggest creating a little Ruby on Rails app. Last year I put together a rails app that did something similar - it displayed a list of Watir scripts as links, and when one was clicked on it would execute the script and display console output in the browser. This worked surprisingly well (even for scripts that used IE#attach, which can cause problems if present in a script that gets started remotely). I stopped before adding the ability to locate and display logfiles, though. But that wouldn't be too hard to do. In all it only took 5 rails controllers (less than 100 lines total) and 5 or 6 separate views. (And I'm sure it could be compacted even more.) I came out of the experience pretty impressed with rails. If there's interest I can try to clean up the code and post it. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to clear the cache of the browser?
Someone posted a Ruby snippet here which will clear the IE cache: http://rubyforge.org/snippet/detail.php?type=snippetid=26 I've used it from time to time and it seems to work fine. It uses functions from the MS WinINet API to walk the cache and delete each item. Thanks Bill On 3/5/07, swarna latha [EMAIL PROTECTED] wrote: Before launching a web page , I need to clear the cache / temp files/cookies of the browser. How can I do it ? Can we do a keyword based search on the Wtr general archive list? I seem to find it a bit difficult to go through archive (2004 to 2007) everytime ...maybe I am missing something obvious.. Thanks for the help. Swarna. 8:00? 8:25? 8:40? Find a flick in no time with theYahoo! Search movie showtime shortcut. ___ 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] Attach problem when remotely running tests using telnet
I also ran into this problem a while back. After trying the same options you listed, I wound up working around it by using Windows task scheduler to run the scripts that needed the attach method. It was a bummer to not be able to manually start the scripts from a remote machine whenever I wanted, though. A while later, I was introduced to the Ruby gserver library. A quick test seems to show that the attach method works fine when I remotely start a Watir script using a little gserver-based server. So, this might solve the problem for you too. Below I've pasted my gserver script. When this is run, it loops forever listening on 0.0.0.0 port 10001. So, if you open a browser on an external machine and point it at http://[your-hostname]:10001, it should execute the serve() method and the system('ruby attach_test.rb') statement inside it. The script expects attach_test.rb in the same dir as the gserver script. Also, I suppose you'd need to set up a Windows firewall exception if you have it enabled. watirserver.rb: == # Executes 'attach_test.rb' whenever someone connects to port 10001 require 'gserver' class WatirServer GServer def initialize(port=10001, host='0.0.0.0') super(port, host, Float::MAX, $stderr, true) end def serve(io) system('ruby attach_test.rb') end end server = WatirServer.new server.start server.join == attach_test.rb : == require 'watir' ie = Watir::IE.new.goto('www.google.com') ie2 = Watir::IE.attach(:title, /Google/) ie2.text_field(:name, 'q').set('Ruby') ie2.button(:name, 'btnG').click == ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I want to use Watir to test Firefox and Safari
As for trying out FireWatir, you can get a prebuilt copy of the JSSh extension (as well as the most recent installation instructions and code) at the google code site: http://firewatir.googlecode.com/svn/trunk/Installation/ If you use that, you shouldn't need to rebuild firefox. I think you can also use the same Watir install for both vanilla IE testing as well as FireWatir, but this involves manually replacing a few watir files with development versions (IIRC). It does take a few extra minutes to set up and get used to using, but FireWatir does work. That said, I haven't been able to make serious use of it yet because of the slow execution speed. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] WinClicker - too many callbacks are defined
The version of DL that's currently in the Ruby standard library has a hard-coded limit of 10 callbacks. According to this post from last summer, some fixes in WinClicker methods were contributed to Watir 1.5, to work around this problem: http://rubyforge.org/pipermail/wtr-general/2006-July/006828.html ..., but maybe your code is running into the same issue in some method that hasn't been patched? Or your winClicker.rb doesn't have those changes for some reason? Not sure. You can probably fix this yourself by adding a call to DL.remove_callback in the method (in the WinClicker class apparently) that is causing the problem. Once you are done using the callback, you just pass DL.remove_callback the name of the callback that has been defined: == enum_windows_proc = DL.callback('IL') { |hwnd| found hwnd 1 # continue enumeration until all windows have been processed } EnumWindows.call(enum_windows_proc, 0) # Enumerate all windows DL.remove_callback(enum_windows_proc) # Now remove the callback. == Incidentally I have had to make use of #remove_callback in a Win32::GuiTest workalike I've been slowly putting together. I decided to try to use Ruby DL for everything, instead of Win32API + C extensions, so the heart of the library (the code to enumerate windows) depends on DL.callback and DL.remove_callback. :) So far #remove_callback has not given me any problems at all. Otherwise Mark's suggestion of reusing a single WinClicker object, instead of instantiating several, is worth trying. Thanks Bill On 10/27/06, George Hawthorne [EMAIL PROTECTED] wrote: Hi, The application I'm testing uses lots of modal Javascript alerts with 'OK' and 'Cancel' buttons. I'm using WinClicker to handle them and it works very nicely until you get to the 11th pop-up, at which point it throws the error: DL::DLError: too many callbacks are defined. Watir version is 1.5.1.1119 and IE version is 7. Details are below. I'd be grateful for any thoughts. Here's a test that consistently produces the error. It always works perfectly for the first 10 instances and then fails on the 11th instance... def test001 1.upto 20 do |i| puts i.to_s # add an object $ie.button(:id, addrow).click # delete the object $ie.button(:id, deleterow).click_no_wait # this throws up a Javascript alert # click OK on the pop-up hwnd = $ie.enabled_popup(5) # get a handle if one exists if (hwnd) w = WinClicker.new w.makeWindowActive(hwnd) w.clickWindowsButton_hwnd(hwnd, OK) end $ie.wait end end Here's the output... Started 1 2 3 4 5 6 7 8 9 10 11 E Finished in 38.226 seconds. Thanks, George ___ 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] file download
Here's a way to get a binary file and save it locally using net/http, built from the example on this site: http://www.rubynoob.com/articles/2006/08/21/how-to-download-files-with-a-ruby-script # Save the google logo.gif to the current dir. require 'net/http' Net::HTTP.start(www.google.com) do |http| resp = http.get(/intl/en/images/logo.gif) open(google.gif, wb) { |file| file.write(resp.body) } end puts Done! == This would of course need changes if you have to deal with authentication or HTTPS. :) - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4399messageID=12417#12417 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] report failure question?
Here are some other suggestions: 1) Perhaps try adding messages to your asserts. If you just want some extra logging when failures occur, this may be all you need to do. All the assert methods I've seen support this; just add the message as the last arg you pass to the assert call. The message will show up in the test results if the test fails (even when using Test::Unit::Reporter; the message will be in the type column for failed test methods). And as you might expect, you can use #{} to interpolate variables in the message (from what I've seen, at least. :) ). This is really useful if you want to have extra descriptive text beyond nil is not true after failed asserts. For example: assert($ie.link(:text, nameOfLink).exists?, Link with text '#{name_of_link}' was not found!) 2) Another cool technique that Bret suggested to the list a month or so ago: See http://www.mail-archive.com/wtr-general@rubyforge.org/msg04849.html - Add this method to your test class: def verify boolean, message = 'verify failed.' add_assertion add_failure message, caller unless boolean end - Now call the verify method instead of assert, and your test will continue executing even if the verification fails: test_testMethodFoo result = verify($ie.link(:text, nameOfLink).exists?) puts Test is still executing... if !result do_some_extra_stuff() end end I may not be using that method in the intended fasion, but this technique brings up a lot of possibilities, regardless. Thanks Bill On 9/22/06, Luke [EMAIL PROTECTED] wrote: I answer myself I've done something like this: begin assert($ie.link(:text, 'name_of_link').exists?) rescue =e #my extra code to do something when assert failed, then i return exception raise end now it seems to work, does anyone know better way? Luke ___ 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] cell access
I don't think Watir (1.4.1, at least) has built-in support for the th tag. But if you know the index of that span in the document, you can get to it using $ie.span(:index, theIndex) Otherwise, if you really need to interact with the TH itself, you may need to use Watir 1.5.x and its new XPath support (unless 1.5 already has a class for TH). The list archives have examples of using XPath to access unsupported elements. On 9/22/06, Luke [EMAIL PROTECTED] wrote: Sorry for asking but I can't deal with it, I've got a table on page and I want to get to the cell Action can someone show me how to do it, I can't firgure out and fail all the time table id=form1:ReportUnit:tblDetails style=font-size: 11px;width: 640px class=Tbl border=0 cellpadding=0 cellspacing=0 caption id=form1:ReportUnit:tblDetails:_titleBar class=TblTtlTxtDetail /caption tr id=form1:ReportUnit:tblDetails:tableRowGroupS:_columnHeaderBar:0 th id=form1:ReportUnit:tblDetails:tableRowGroupS:colLinkS:_columnHeader class=TblColHdr align=center scope= colspan class=TblHdrTxtAction/span/ th ... ___ 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] report failure question?
Whoops, my verify example was meant to be more like this: test_testMethodFoo result = $ie.link(:text, nameOfLink).exists? verify(result) puts Test is still executing... if !result do_some_extra_stuff() end end ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] cell access
Ah, yes. It's been so long since I looked at any table code I forgot that the easiest way is to get cells is to use table.[index][index]. That does indeed work fine with the th tags in Luke's HTML snippet. By support I meant that there is no TableHeader class in Watir, but accessing table headers works fine without one. :) On 9/23/06, Paul Carvalho [EMAIL PROTECTED] wrote: Umm.. I have no idea what you're talking about, Bill. th is just a td with some fancy formatting. I see no reason why a command like the following wouldn't work with Watir 1.4.1: irb ie.table(:index, 1)[1][3].flash As with anything you do, there are usually a few ways to get to a particular object on a page. You could just try to use the table(..)[row#][col#].whatever approach, or you could try to just access the span tag directly (as you suggested) and completely ignore the table. Luke, in order for us to know what kind of advice to offer, it might help for you to also tell us what you have tried. Including the section of html was good, but not enough. Is the table in a frame? Is the Action just a text label, or also a link? Trying to get to something is not always straightforward by zooming in on the target. Sometimes you have to step back and take in the big picture too. Paul C. On 22/09/06, Bill Agee [EMAIL PROTECTED] wrote: I don't think Watir (1.4.1, at least) has built-in support for the th tag. But if you know the index of that span in the document, you can get to it using $ie.span(:index, theIndex) Otherwise, if you really need to interact with the TH itself, you may need to use Watir 1.5.x and its new XPath support (unless 1.5 already has a class for TH). The list archives have examples of using XPath to access unsupported elements. ___ 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] report failure question?
Are you using Test::Unit::Reporter? It could be useful to put together a small demo script that will demonstrate the problem. So it sounds like you have a test that is expected to fail, and it's not failing? (Or is it that the script is behaving properly, but the report does not have the correct result for the test?) Which assert method are you using? Might be something that could be easily fixed... On 9/21/06, Luke [EMAIL PROTECTED] wrote: I have test, I use assert method and in the end I generate report for this test case, the problem is that when I put 'rescue=e' statement I catch exception and report shows that test pass, if I remove rescue block, then in report I have error in appropriate colum, but still when test is suppose to fail, failure column in report is empty, can you tell me how can I get information when test was done and when fail and present it in report? now I put log to file if assert fails Luke ___ 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] Send results to console and text file
On 3/23/06, Padhma N [EMAIL PROTECTED] wrote: Hi, I have 2 questions. (1) I would like to send the results of my test suite to a .txt file and also want the results to be seen on the console. How do I do that? I know that I can use the following command in the command prompt- function1.rb results.txt But I want something more like,the program itself directing its each output to both the console and the results.txt file. I tried f.syswrite but that seems inefficient as I have to use f.syswrite at all places I use puts statement. Is there a better way to do this? Not sure of a way to do your question (2). However, as for question (1) I was sort of able to split output from running a suite to $stdout and a file, by passing an io handle into TestRunner.new(), then using to send the test run output to $stdout as shown in this example: require 'test/unit/testsuite' require 'test/unit/ui/console/testrunner' outputFileName = 'suite.log' outputFileHandle = File.new(outputFileName, w+) ...require test cases and create suite here... # create new runner and start suite: $stdout Test::Unit::UI::Console::TestRunner.new(TS_MyTests, output_level=2, io=outputFileHandle).start However, while this puts all the runner output into 'suite.log', only the final summary line (with the number of tests/assertions/failures/errors) is displayed on the console. So what I currently do in this case is just 'tail -f suite.log' using Cygwin's tail util to get up-to-the-minute status as the suite runs. :) However, I'm sure there's some way to direct the script to send all the output to $stdout as well as the suite logfile. I just haven't run across it so far... Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] WindowLogonExample.rb - should it work for me?
That particular unit test works fine for me on XP Pro SP2, however I installed Watir using the win32 .exe installer. From the look of things you installed with the .gem, I wager? It could be the autoit DLL is not registered on your system. Perhaps installing with the .gem doesn't handle that automagically in some (all?) cases? I've never used the Watir .gem so I can't say for sure. Try manually registering the autoit DLL using regsvr32, and then try the unit test again: regsvr32 \ruby\lib\ruby\site_ruby\1.8\watir\AutoItX3.dll Thanks Bill On 3/13/06, philip reed [EMAIL PROTECTED] wrote: I'm having trouble getting WaTiR to interact with authentication dialogs or Javascript dialogs (i.e. Are you sure?-style messages). I've found that unittests/WindowLogonExample.rb also doesn't run for me, generating the following error on Windows XP sp 2 Home: C:\ruby\lib\ruby\gems\1.8\gems\watir-1.4.1\unittestsruby WindowLogonExample.rb Loaded suite WindowLogonExample Started ./../watir/WindowHelper.rb:5:in `initialize': unknown OLE server: `AutoItX3.Cont rol' (WIN32OLERuntimeError) HRESULT error code:0x800401f3 Invalid class string from ./../watir/WindowHelper.rb:5:in `initialize ' from WindowLogonExtra.rb:6 . Finished in 333.296 seconds. 1 tests, 0 assertions, 0 failures, 0 errors (333.296 seconds was where I shut down MSIE manually; AFAICT the test would have hung indefinitely had I not done so.) My due diligence search of the archive found a bunch of references to this thread from August '05 that doesn't sound too certain that this test should be working now: http://rubyforge.org/pipermail/wtr-general/2005-August/002861.html I also found this thread from June that sounds like it was working then: http://rubyforge.org/pipermail/wtr-general/2005-June/002241.html My next step will be to take the latest CVS and see whether that works in my environment. Meanwhile, can someone please confirm that this *SHOULD* work on a normal Windows XP installation, i.e. that I'm not spending time to troubleshoot a test that's known to fail for whatever reason? Thanks, Philip -- Philip Reed, Developer Positronic Design http://www.positronicdesign.com ___ 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] Unknown OLE server: `AutoItX3.Control' (WI2OLERuntimeError)! Why?
On 3/2/06, Paatsch, Bernd [EMAIL PROTECTED] wrote: :/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1311:in `initialize': Unknown OLE server: `AutoItX3.Control' (WI2OLERuntimeError) Maybe AutoItX.dll didn't get registered on his machine during the Watir install? I've never had to register it manually with the most recent Watir version, but I guess it's worth a try. You can try manually registering the dll on that machine, using the path to the file, like so: regsvr32 C:\ruby\lib\ruby\site_ruby\1.8\watir\AutoItX3.dll ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Script hangs and does nothing
On 2/23/06, saud aziz [EMAIL PROTECTED] wrote: BTW, does it work for any of you? For me it errors out on the image call at line 12. I didn't check the page source to see if the image is missing/named something else/etc. Also, at first the script would hang for me; then I tried running it with test/unit's --verbose=verbose flag, and suddenly it started dying at line 12. Not sure if I changed something else to cause it to stop hanging, or it if's just something weird with test/unit. Here was the error I got: --- Started E Finished in 14.328 seconds. 1) Error: test_recorded(TC_recorded): Watir::Exception::UnknownObjectException: Unable to locate object, using id and template_ib_GetStarted c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1928:in `assert_exists' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2009:in `click' C:/temp/watirlist/sym.rb:12:in `test_recorded' 1 tests, 0 assertions, 0 failures, 1 errors ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Update on Clicking Windows File Download - Security Warning Dialog Box
On 2/17/06, Chris Schmechel [EMAIL PROTECTED] wrote: I was able to write a Perl Win32::GuiTest to do the following: @window = FindWindowLike(0,File Download,); SetForegroundWindow($window[0]); SendKeys({SPACE}); It seems pretty common for people to call a helper script like the one above in order to unblock IE after a browser action that spawns a popup. I ran into at least one case where running a small helper Ruby script similar to the above was the only way to dismiss a certain pesky popup window. One pattern to solve this is: - start a ruby thread inside it, click the link/button or whatever that causes IE to block - sleep a bit in between the thread definitions (or write some code that will wait until the popup window you're watching for appears) - start another thread inside it, use system() to execute your helper script, which hopefully dismisses the popup - join both threads and resume program flow, assuming the popup has been dismissed and the call to IE that spawned the popup has now returned Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Verify HTTP 200 OK response
On 2/15/06, Chris Schmechel [EMAIL PROTECTED] wrote: Is there an equivalent method in Watir or something I can query in the DOM to return the HTTP status after the ie.button().click method finishes? It would be nice to have something similar to $mech-status in Perl. I'm only aware of the ie.contains_text() method which isn't quite right. Hi Chris! From a glance at watir.rb it looks like some error checking is done internally as you navigate, using the 'check_for_http_error' method. However as far as I can tell, that checks for shdoclc.dll in the current URL, which may not be what you want. In this sort of case, after a click, I just go ahead and start asserting for the existence of values I know should be on the resulting page. Then if any of the asserts fail I know the point where something went wrong. I guess alternately if the web app uses a custom 404 page that overrides IE's default you could assert/check that the 404 page text is not present. There could be some part of Watir I haven't seen where more HTTP status code checking lives, or maybe there's a quick way to use the IE OLE interface directly to get the status. I glanced over the MSDN reference but nothing 'clicked' as far as an easy way to do it. Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Declarative Watir scripts?
On 2/9/06, Brian Vallelunga [EMAIL PROTECTED] wrote: As I was typing in line 261 of very basic and repetitive Watir code, I that much of this scripting should be able to be done declaratively, especially when using the scripts to simply input values and check responses. Has anyone done anything like this? I currently use a little homebrew framework like this. I just have a big batch of XML files that contain elements like button name=name method=click / and so forth, contained inside step elements, and a driver script that parses the XML files and turns the contents into Watir statements. For complex cases that require more code (like popup handling) I just make special tags whose name correspond to methods that contain the special case code. However, I'm strongly considering a change, using Test::Unit instead of continuing with my own stuff. This is because I'm trying to figure out the best way to hand over the framework to the dev team to use, and my module for handling my XML files feels kind of kludgey. I also don't want people to have to discover limitations with my XML format and have to hack on that to handle new cases. Also, using a standard unit testing format rather than something I threw together will probably be more appealing to the dev staff where I work. :) On the other hand, not using the XML config files will probably make for a steeper learning curve. The tradeoffs are interesting. There's also WET (http://wet.qantom.org/overview.html) which I haven't looked at in depth, but might be applicable for what you want. Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Declarative Watir scripts?
On 2/9/06, Hugh Sasse [EMAIL PROTECTED] wrote: On Thu, 9 Feb 2006, Bill Agee wrote: On the other hand, not using the XML config files will probably make for a steeper learning curve. The tradeoffs are interesting. Why is this, do you think? OK, XML syntax is pretty standard, but the semantics will have to be learned. At least with Ruby you can add new methods which wrap behaviour, if you wish to simplify common cases. Which aspects of the Ruby syntax present difficulties for the newcomer? I could probably have told you a few years back, but now I'm fairly used to it, and in the domain of testing, I cannot consider this to be obvious. But it may be that commonly confusing cases may be re-written to be clear. I was mainly thinking about non-programmers; for testers without programming experience, using an XML testing language to build tests could result in more success up front (which I think is important in sustaining interest in automated testing, and keeping people from abandoning automation suites/frameworks/etc). Along the same psychological lines, learning by modifying existing cases written in XML could feel less intimidating than learning by reviewing raw Ruby scripts. But I agree that Ruby is pretty painless to learn. So much so that those wanting to use a Ruby framework for testing are better off knowing enough of the language to compose test cases in Ruby, without too much abstraction (whether into XML or some other format). Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Apache User Authentication
On 1/30/06, Terry Peppers [EMAIL PROTECTED] wrote: I was looking through the old Watir mailing lists for some information on how I might be able to bypass the Apache user authentication on our staging machine without using AutoIt. I didn't come up with much aside from use - AutoIt. One of our developers recommended I should try the following URL: http://username:[EMAIL PROTECTED] ... Yeah, the http://user:[EMAIL PROTECTED] thing used to work in IE too, but support for that was removed at some point after it began to be widely used as part of a technique to spoof URLs in phishing emails. :) Anyway, you might want to look at the 'WindowLogonExample.rb' and 'WindowLogonExtra.rb' files in the Watir unit tests. Those are more the kind of thing you want, I think. And one of the things that helped me understand ways to use autoit was looking over '\ruby\lib\ruby\site_ruby\1.8\watir\WindowHelper.rb'. Up to and including Watir 1.4.1, it seems this type of task is usually accomplished using multiple Ruby threads, in order to get around the fact that IE blocks when you request a URL that spawns a popup or prompt. The code in one of the threads often just runs a second Ruby script (as shown in WindowLogonExample.rb / WindowLogonExtra.rb). I think the development version of Watir has some fancy new stuff that helps in this area, but I haven't looked at it yet. Anyway, here's a distilled example of the thread technique that might work as a standalone script for your case: - require 'watir' require 'win32ole' autoit = WIN32OLE.new('AutoItX3.Control') # URL that kicks off the basic auth prompt: url = http://quantico.int.apg.aventail.com/secured/; # The title of the prompt dialog: prompt = Connect to quantico.int.apg.aventail.com user = user1 pass = user1 a = Thread.new { ie = Watir::IE.start(url) } b = Thread.new { autoit.WinWait prompt, autoit.Send(user) autoit.Send({TAB}) autoit.Send(pass) autoit.Send({ENTER}) } a.join b.join ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [(SPAM) - Tagged by Sybari Antispam] Re: close all IE windows
On 1/24/06, Richard Lawrence [EMAIL PROTECTED] wrote: ... Unfortunately, fixing the bug doesn't get rid of the orphan IE window from the last run of the test suite. And because of the way my team develops smoke tests for this app, this is a common pattern for a bug in smoke tests; the smoke test system ought to be able to catch and handle it gracefully. This happens to me all the time too. I've been meaning to try out this solution mentioned on the list in November: http://www.mail-archive.com/wtr-general%40rubyforge.org/msg01861.html I haven't tried it out yet, though. I think that was the solution someone referred to earlier in this thread. Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] threads to close security - working unless it doesn'tcome up.
Title: Message I think that happens because the autoit WinWait callinsidethe 'push_security_alert_yes' method doesn't have a timeout value.Soit waits forever,looking for the "Security Alert" window. You can check out the details of how that popup is dismissed bylookingin your localcopy of WindowHelper.rb (which should be in \ruby\lib\ruby\site_ruby\1.8\watir\). A good way towork around thismight be towrite your own autoit method that copies exactly what 'push_security_alert_yes' does, but with a timeout added. As a quick test you could try adding thisto your "b" thread (after commenting out the WindowHelper stuff in the thread): require 'win32ole'autoit = WIN32OLE.new('AutoItX3.Control')autoit.WinWait "Security Alert", "", 5autoit.Send "{TAB}"autoit.Send "{TAB}"autoit.Send "{SPACE}" I think that should work (I didn't test it,though). The only major difference between that and 'push_security_alert_yes' is the "5" value added to the end of WinWait. So I guessifyoudon't mind editing the libraryyou could make the change (or add a new method) in WindowHelper.rb. But in the long term, the change might get lost in an upgrade or something, so... Docs on WinWait and many more usefulautoit functions are inAutoItX.chm (or http://www.autoitscript.com/autoit3/docs/functions.htm). Thanks Bill -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jon PassmoreSent: Tuesday, January 17, 2006 3:58 PMTo: wtr-general@rubyforge.orgSubject: [Wtr-general] threads to close security - working unless it doesn'tcome up.I am testing stuff on two different servers. on one server I get a security alert which I am taking care of with this:a = thread.new {code here...}b = Thread.new { sleep 1; helper = WindowHelper.new; helper.push_security_alert_yes;}If the security alert doesn't pop up as is true on the second server, the code in A just sits there like it is waiting for b to finish up and join it.Please help.Thanks.Jon ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to manipulate attaching files
Title: Message I think file fields are treated as a different type of object than text fields. But you should be able toset file fields using 'fileField'...here's an example from the "filefield_test.rb" WATIR unit test: $ie.fileField(:name,"file1").set($htmlRoot + "fileupload.html") Using this hasworked fine for me so far, at least for for simple file uploads. ThanksBill -Original Message-From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]Sent: Thursday, December 15, 2005 11:30 AMTo: wtr-general@rubyforge.orgSubject: [Wtr-general] How to manipulate attaching files I may have posted twice. Looks like the first one did not make it through. Ihave web application that requires attaching a file very similar to attaching a file in Yahoo mail. Rather than manipulating the attach button, navigating to the file and attaching it, I thought I would use a short cut by writing directly into the text field the path to the file. However, using this approach returns an UnknownObjectException. To illustrate, I'm using the text field method ie.text_field(:name, "typeinme").set("some text") input type = "text" name = "typeinme" However, in my html reads like this: input type = "file" name = "typeinme" Does anybody have any ideas how to solve this problem? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Controlling threads testing speed
-Original Message- Subject: [Wtr-general] Controlling threads testing speed What tricks are available for timing threads and controlling the speed of WATIR? How can we make sure a thread has ended? The basic concern is that the WATIR script will work, then it may not work, and eventually it will work again without any modification to the code or application. These scripts involve modals and pop ups. I believe it is a timing issue, but I am not certain. Has anyone else experienced this type of behavior? [...snip...] I too initially had some problems with timing issues in my popup-dismissing threads. But since then I've had success using sleep() mixed in with creation of threads, as in the example below. Since doing this I've had no further problems with timing issues and simple popup dismissing tasks (knock wood): = def navigate (address) req01 = Thread.new { goto(address) } # wait a sec for the 'entering HTTPS' IE prompt to appear: sleep(1) # dismiss first IE prompt: req02 = Thread.new { btnclk('Security Alert', 'OK') } # wait for the SSL y/n/cancel prompt to appear: sleep(1) # another button click to dismiss the SSL cert prompt: req03 = Thread.new { btnclk('Security Alert', 'Yes') } # wait for all threads to complete before continuing: req01.join req02.join req03.join end = (The 'btnclk' method shown above is just a wrapper around an autoit-like DLL I'm using to dismiss windows.) Thanks Bill ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general