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
[Wtr-general] Watir_Simple Handle Exhaustion
Watirists: I am still wondering how anyone TDDs with this system. I am currently trying to use Watir_Simple (because it will take care of all the wait-for-refresh issues that I don't want to research.) However, it exhausts handles. Further, I can't figure out how to reach inside it and grab the IE object it holds. (Is this @@browser?) Does anyone have a complete, TDD-ready example of Watir_Simple in action, such as one testing a public web site? So I can run it and report if it exhausts my handles? -- 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
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
[Wtr-general] nested tables
I'm writing scripts to test a web site I didn't write myself. This web site has nested tables … not all of them have names … noobs.How do you access nested tables in watir? I've tried everything and am at my wit's end. I'm about ready to just grep the source code for the links, but I'd rather not do that. -- Vincent___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] cell access
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 getto 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 alreadyhas a class for TH).The list archives have examples of using XPathto access unsupported elements. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir_Simple Handle Exhaustion
Phlip wrote: I am still wondering how anyone TDDs with this system. I am currently trying to use Watir_Simple (because it will take care of all the wait-for-refresh issues that I don't want to research.) However, it exhausts handles. Further, I can't figure out how to reach inside it and grab the IE object it holds. (Is this @@browser?) Does anyone have a complete, TDD-ready example of Watir_Simple in action, such as one testing a public web site? So I can run it and report if it exhausts my handles. Did you see the recent post by Aslak Hellesoy where he showed a simple framework for using Watir with Rspec to do TDD? (or BDD) ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir Q's
David Munns wrote: Based on what I see in the watir unit tests, I have tried: ie.modal_dialog( :title, /Modal Dialog Partial Title/ ) = result is a watir timeout, even when I set timeout value at 60s It appears that the window is never found this way. Any suggestions? ie.modal_dialog() Once the modal dialog window is launched, if I want to click the “OK” button, is this the correct way? ie.button( :value, “OK” ).click No. This: ie.modal_dialog.button(:value, 'OK').click Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] nested tables
I've done a lot of web scraping, where we have to deal with whatever HTML the developer hacked together. Nested tables without id's or name's can be a pain, but they can be dealt with. The methods may be different depending on which version of Watir you're running though. I'm using 1.5 from trunk here, and I recommend using one from trunk, even though they're not officially released yet. In these cases, IRB is your best friend. Here I've opened the browser to table1.html in the unittests\html directory. I then start up IRB and connect to that browser: C:\Documents and Settings\davidsirb irb(main):001:0 require 'watir' = true irb(main):002:0 include Watir = Object irb(main):003:0 ie = IE.attach(:title, /Test/) [...] Next, we look to see what tables we have: irb(main):008:0 ie.show_tables Found 6 tables 1 id= rows=2 columns=2 2 id=t1 rows=5 columns=1 3 id=t2 rows=2 columns=2 4 id= rows=1 columns=2 5 id=body_test rows=5 columns=1 6 id=pic_table rows=1 columns=4 = nil irb(main):009:0 Here we'll look for the nested table example. Looks like table 3 matches the nested table on the screen. Note that table 4 is the table *inside* table 3! We can confirm these guesses by showing the HTML for each table: irb(main):010:0 ie.table(:index, 3).html = \r\nTABLE id=t2 border=1TBODY\r\nTR\r\nTDcell 1 \r\nTDcell2 \r\nT R\r\nTD\r\nTABLE\r\nTBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY /TABLE\r\nTDNormal /TR/TBODY/TABLE irb(main):011:0 ie.table(:index, 4).html = \r\nTABLETBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY/TABLE irb(main):012:0 Sure enough, you can see table 4 there in the middle of table three. The reason this is important is because you can use indexes to find cells in a table: irb(main):013:0 ie.table(:index, 3)[1][1].text = cell 1 The trick is that the embedded tables are counted as part of the containing table. This is why the row_count for table 3 shows *3* rows instead of two: irb(main):014:0 ie.table(:index, 3).row_count = 3 It's counting it's own two rows, plus the one row in the containing table. Row 3 is the table 4's row 1, but though row_count reports 3 rows, it won't let you ACCESS row 3, because it's really in table 4! irb(main):016:0 ie.table(:index, 3)[2][1].text = nest1nest2 irb(main):017:0 ie.table(:index, 3)[2][1].html = \r\nTDTABLE\r\nTBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY/T ABLE irb(main):018:0 ie.table(:index, 4)[1][1].text = nest1 irb(main):019:0 ie.table(:index, 4)[1][2].text = nest2 irb(main):020:0 ie.table(:index, 3)[3][1].html WIN32OLERuntimeError: Unknown property or method `2' HRESULT error code:0x80020006 Unknown name. from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `[]' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `row' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3140:in `[]' from (irb):20 irb(main):021:0 ie.table(:index, 3)[3][1].text WIN32OLERuntimeError: Unknown property or method `2' HRESULT error code:0x80020006 Unknown name. from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `[]' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `row' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3140:in `[]' from (irb):21 irb(main):022:0 That last row must be accessed via table 4. There have been some discussions about fixing this inconsistency and I've argued towards accuracy where row_count would only report the rows in it's OWN table, and sub-tables would be accessed for their row count, but others have been afraid of breaking existing tests which already account for the inaccurate count. Hope this helps you address the cells in your nested table situation. David Schmidt Vincent Predoehl wrote: I'm writing scripts to test a web site I didn't write myself. This web site has nested tables … not all of them have names … noobs. How do you access nested tables in watir? I've tried everything and am at my wit's end. I'm about ready to just grep the source code for the links, but I'd rather not do that. -- Vincent ___ 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