Re: [Wtr-general] passing control from watir ie instance to wet...
You wont be able to use a Watir ie object instance in WET. To dismiss the dialog, you could use: Browser(title:=your title here).Dialog(title:=Microsoft Internet Explorer).Button(value:=OK).click and it should work. Thanks Raghu Roy Sin wrote: In my testsuite I have passed my IE instance to a variable $ie and i have been using mostly Watir commands with that variable as in ... def test_03_add_asset ... $ie.frame(main).image(:src, /add_asset/).click ... end ... but on my last test case I need to close a confirmation popup. I included WET and tried both Browser(title:=Microsoft Internet Explorer).Button(value:=OK).click and $ie.Browser(title:=Microsoft Internet Explorer).Button(value:=OK).click but in both cases that didn't work. How can I instruct the Browser command to use the same ie instance? thanks __ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general -- Qantom Software http://www.qantom.com Ph : 91-80-26799269 Xtn. 125 sip : [EMAIL PROTECTED] -- ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] [ wtr-Bugs-2720 ] minimize/maximize don't work without prior browser navigation
Bugs item #2720, was opened at 2005-10-26 03:01 You can respond by visiting: http://rubyforge.org/tracker/?func=detailatid=487aid=2720group_id=104 Category: None Group: None Status: Open Resolution: None Priority: 3 Submitted By: Meg Solley (megsolley) Assigned to: Nobody (None) Summary: minimize/maximize don't work without prior browser navigation Initial Comment: The following code: ie = Watir::IE.new ie.maximize results in this exception: c:/depot/tools/win32/ruby-1.8.2/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:12 37:in `method_missing': document (WIN32OLERuntimeError) OLE error code:80004005 in Unknown No Description HRESULT error code:0x80020009 Exception occurred. from c:/depot/tools/win32/ruby-1.8.2/lib/ruby/ge ms/1.8/gems/watir-1.4.1/./watir.rb:1237:in `title' from c:/depot/tools/win32/ruby-1.8.2/lib/ruby/gems/1.8/gems/watir-1.4.1/ ./watir.rb:1314:in `set_window_state' from c:/depot/tools/win32/ruby-1.8.2/lib/ruby/gems/1.8/gems/watir-1.4.1/ ./watir.rb:1294:in `minimize' from test.rb:11:in `test' from test.rb:15 However, this code: ie = Watir::IE.new ie.goto(http://www.google.com;) ie.maximize works just fine. -- You can respond by visiting: http://rubyforge.org/tracker/?func=detailatid=487aid=2720group_id=104 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Testing If a Checkbox is Checked by Default
Is there anyway in Watir to test a webpage to see if a Checkbox is checked by default? I can access the checkbox name and verfy that there's a value with the following: - BEGIN CODE --- assert(@ie.checkbox(:name, other_offers)) assert(@is.checkbox(:value, other_offers).exists?) - END CODE --- But how can I tell if the box is checked? I tried using 'set' - but I don't think that's correct. Can this be tested? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [ wtr-Bugs-2720 ] minimize/maximize don't work without prior browser navigation
Dear all, Can anyone help me out with this first step. I got error when i test the file unittest.rb in C:\watir\unittest.rb. Here is the error:- c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1160:in `check_for_http_error' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1141:in `set_defaults' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1135:in `call' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1436:in `run_error_checks' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in `each' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in `run_error_checks' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1419:in `wait' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1254:in `goto' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2797:in `save' C:/Watir/unittests/../unittests/images_test.rb:160:in `safe_file_block' C:/Watir/unittests/../unittests/images_test.rb:160:in `each' C:/Watir/unittests/../unittests/images_test.rb:160:in `safe_file_block' C:/Watir/unittests/../unittests/images_test.rb:143:in `test_save_local_image' 7) Error:test_save_local_image_returns_original_page(TC_Images):Watir::Exception::NavigationException: Cannot find server or DNS Error c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1160:in `check_for_http_error' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1141:in `set_defaults' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1135:in `call' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1436:in `run_error_checks' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in `each' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in `run_error_checks' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1419:in `wait' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1254:in `goto' c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2797:in `save' C:/Watir/unittests/../unittests/images_test.rb:160:in `safe_file_block' C:/Watir/unittests/../unittests/images_test.rb:160:in `each' C:/Watir/unittests/../unittests/images_test.rb:160:in `safe_file_block' C:/Watir/unittests/../unittests/images_test.rb:153:in `test_save_local_image_returns_original_page' 8) Failure:test_front(TC_MinMax) [C:/Watir/unittests/../unittests/minmax_test.rb:22]:false is not true. 9) Failure:test_confirm(TC_PopUps) [C:/Watir/unittests/../unittests/popups_test.rb:36]:false is not true. 10) Failure:test_links_and_images_in_table(TC_Tables) [C:/Watir/unittests/../unittests/table_test.rb:165]:106 expected but was28. 182 tests, 1048 assertions, 8 failures, 2 errors C:\Watir\unittestsall_tests.rbLoaded suite C:/Watir/unittests/all_testsStarted..FF..F...Starting win setFileDialogin new process. Setting text file://C:/Watir/unittests/html/fileupload.htmlStarting app: c:/ruby/lib/ruby/site_ruby/1.8/watir/setFileDialog.rb file://C:/Watir/unittests/html/fileupload.html...---Objects in page - id= src="">button name=b1 id=b2 value=Click Me alt= src=""> id= id= value=0 id= value=0checkbox name=check1 id= value=10 alt= src="">checkbox name=check1 id= value=20 al t= src="">checkbox name=check1 id= value=30 alt= src="">radio name=r1 id= value=a al t= src="">radio name=r1 id= value=b alt= src="">radio name=r1 id= value=c alt= src= "">radio name=r1 id= value=d alt= src="">text name= id=t1 value= alt= src=""> text name= id=t2 value= alt= src="">select-one name=s1 id= value=select-multiple name=s2 id= value= submit name= id= value=Submit alt= src="">reset name= id=reset_button value=Reset alt= src=""> text name=g1 id= value=textfield alt= src="">button name=g1 id= value=button alt= src="">checkbox name=g1 id= value=1 al t= src="">radio name=g1 id= value=2 alt= src="">text name= id=g1 value=textfield_id al t= src="">button name= id=g1 value=button_id alt= src="">checkbox name= id=g1 value=1_id alt= src= "">radio name= id=g1 value=2_id alt= src="">text name=tt1 id= value= alt= src=""> image name=imm id= value= alt=submit src="" href="file:///C:/Watir/unittests/html/images/button.jpg">file:///C:/Watir/unittests/html/images/button.jpg hidden name=hid1 id= value= alt= src="">hidden name= id=hidden_1 value= alt= src="">button name= id= value=Show Hidden al t= src="">text name=vis1 id= value= alt= src="">text name=vis2 id= value= al t= src=""> .BODYCVS Revision: $Revision: 1.6 $ BRBRTABLETBODYTRTDFORM action="" method=getINPUT id=b2 type=button value=Click Me name =b1 /FORMTDTRTDFORM name=test2 action="" method=getULLIListItem1LISPANListItem2/SPAN /LI/ULBRINPUT type=checkbox value=10 name=chec k1 BRINPUT type=checkbox value=20 name=check1 BRINPUT type=checkbox value=30 name=check1 BRINPUT type=radio value=a name=r1 selected BRINPUT type=radio value=b name=r1 BRINPUT type=radio value=c name=r1 BRINPUT type= radio value=d name=r1 BRINPUT id=t1 BRINPUT id=t2 BRSELECT name=s1OPTION selected1/OPTION OPTION2/OPTION/SELECT BRSELECT multiple nam e=s2 visible=3 OPTION1/OPTION OPTION2/OPTION OPTION3/OPTION OPTION4/OPTION OPTION5/OPTION OPTION6/OPTION/SELECT BRINPUT type=sub mit value=SubmitINPUT id=reset_button type=reset value=Reset /FORMTDTR bgColor=blueTDINPUT value=textfield name=g1 BRINPUT type=button
Re: [Wtr-general] Testing If a Checkbox is Checked by Default
Hi Terry, Try assert(@ie.checkbox(:name, other_offers).checked?) Alf Terry Peppers wrote: Is there anyway in Watir to test a webpage to see if a Checkbox is checked by default? I can access the checkbox name and verfy that there's a value with the following: - BEGIN CODE --- assert(@ie.checkbox(:name, other_offers)) assert(@is.checkbox(:value, other_offers).exists?) - END CODE --- But how can I tell if the box is checked? I tried using 'set' - but I don't think that's correct. Can this be tested? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general -- Alf Whitehead [EMAIL PROTECTED] 416-214-4977 x260 Quality Assurance Specialist Klick Communications, http://klick.com/ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Testing If a Checkbox is Checked by Default
Try this: ie.checkbox(:id, 'checkbox_id').checked? I found it here http://wtr.rubyforge.org/rdoc/ (Classes Watir::RadioCheckCommon http://wtr.rubyforge.org/rdoc/classes/Watir/RadioCheckCommon.html) Zeljko From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Terry Peppers Sent: Wednesday, October 26, 2005 3:36 PM To: wtr-general@rubyforge.org Subject: [Wtr-general] Testing If a Checkbox is Checked by Default Is there anyway in Watir to test a webpage to see if a Checkbox is checked by default? I can access the checkbox name and verfy that there's a value with the following: - BEGIN CODE --- assert(@ie.checkbox(:name, other_offers)) assert(@is.checkbox(:value, other_offers).exists?) - END CODE --- But how can I tell if the box is checked? I tried using 'set' - but I don't think that's correct. Can this be tested? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Testing If a Checkbox is Checked by Default
Try this: assert(@is.checkbox(:value, other_offers).isSet?) A good resource for examples like this are the unittests, which are installed with WATIR. Hope this helps, --Mark From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Terry Peppers Sent: Wednesday, October 26, 2005 6:36 AM To: wtr-general@rubyforge.org Subject: [Wtr-general] Testing If a Checkbox is Checked by Default Is there anyway in Watir to test a webpage to see if a Checkbox is checked by default? I can access the checkbox name and verfy that there's a value with the following: - BEGIN CODE --- assert(@ie.checkbox(:name, other_offers)) assert(@is.checkbox(:value, other_offers).exists?) - END CODE --- But how can I tell if the box is checked? I tried using 'set' - but I don't think that's correct. Can this be tested? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] undefined method `document' for nil:NilClass = Error
Hi folks, two weeks ago I send a bug to this mailing list about undefined method `document' for nil:NilClass = Error as you can see below, and no one could help me out. Ive found the solution. Its quite simple. You can just launch the sentence written in Watir under your WET script. This seems to be a specific WET bug. I think that maybe useful for any other WET bugs. You can go around the bug using Watir sentences, while a fix is found in WET. I hope this could help to anyone. Cheers -Mensaje original- De: Jesús JCE. Collado Pérez Enviado el: jueves, 13 de octubre de 2005 18:21 Para: 'wtr-general@rubyforge.org' Asunto: undefined method `document' for nil:NilClass = Error Hi folks, I've found a weird error using WET and I'm afraid this may be a WET bug (I hope it's just my fault with code ;-) ) I'm trying to set either a text field and a checkbox that is found in a second level frame as following: Browser(url:=http://server/app/principal.jsp).Frame(name:=frame1).Frame(name:=frame2).TextField(name:=testfield).set Testing The focus move to the text field but it seems to fail when trying to write. This is what I get: undefined method `document' for nil:NilClass = Error This is really driving me crazy so I'll appreciate any kind of help with this issue and hope this help to more people. Thanks in advance Jesús Collado Pérez Testing Engineer Southern Star [EMAIL PROTECTED] Tel: 91 372 80 22 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Help with attach
Im stuck! I have an application that generates a reportthe user: Selects the reports tab Chooses the desired report Select the division and date interval to report on Clicks the Submit button When the submit button is clicked a new window opens (the report itself) with the same name as the parent window that spawned it. I need to be able to get that window (the report) and be able to time its status until it completely renders. The trouble I am having is the test completes long before the spawned-page renders, and I need the test to complete only after the report renders. Any suggestions? Here is my test code: -- Begin Code def test0_runSingle openPage() $ie.link( :text, /A300/i ).click dbList = $ie.select_list( :name, 'DivBranch').getAllContents for dbl in dbList $ie.selectBox( :name, 'DivBranch').select(#{dbl}) end $ie.text_field(:name, dateSelect).set(01/01/2005) $ie.button(Submit).click # Start time stamp for report $start = DateTime.now cw = IE.attach(:title, /RAPID - Reports/i) puts cw.status() assert(cw.contains_text(RAPID REPORT FOR OPERATIONS - A300)) $stop = DateTime.now diff = $stop - $start h,m,s,frac = Date.day_fraction_to_time(diff) s += frac.to_f puts That's #{h} Hours, #{m} Minutes, #{s} Seconds end --- End Code Mark L. Cain LMIT - E*STARS ~ Lead Test Engineer 1981 Snyder, MSIN: G3-62, Richland, WA 99354 [EMAIL PROTECTED] 509.376.5458 640 Kilobytes of computer memory ought to be enough for anybody. - Bill Gates, 1981 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Is there a method to do ie.contains_html() ?
I know about contains_text() but is there some sort of contains_html() feature, or should I build my own method to do this? I notice html() which will output the entirety of the HTML for a page, but is there an easy way to match text within that. I mean to ask.. has anyone written a snippet of code which I can re-use? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] getting the HTTP status
you may want to look at the log4r http://log4r.sourceforge.net/ to have an oject that take care of loging your reports. It may be overkill. Most of my test use the 'rescue = e' way example expected = hello #some text on the homepage @@log.info Expected: Home page Page begin @@ie.goto(homepageurl) assert(@@ie.contains_text(expected)) @@log.info PASS rescue = e @@log.info FAIL end I'm not sure the way below is better, here is a fragment begin assert_nothing_raised(){ (@@ie.link(:text, link_name).click) } @@log.info PASS: got down to #{link_name} rescue = e @@log.info FAIL: did not get to #{link_name} end cheers Pierre garigue -Original Message- From: Sy Ali [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 26, 2005 1:30 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] getting the HTTP status On 10/21/05, Pierre Garigue [EMAIL PROTECTED] wrote: I because I 'rescue' everything, getting a 500 or 404 would just give me a fail. I would like to add info to the log that is failed and got this http status. I too am using the basic rescue technique, which doesn't really give me a whole lot to work with. I read through the technical docs[1] and couldn't find anything more specific. Perhaps this feature does not exist? I wonder what would happen if I turned on friendly error messages .. then if rescue catches the error, could I scan the page or title to determine the nature of the error? Here is my go to method, used with goto(http://example.org/foo/bar.html;) or goto(variable). It's different than yours because it notices succesfully-loaded, but redirected pages: def goto(url) begin puts * going to + url $ie.goto(url) rescue puts ERROR else putsok, destination loads end if $ie.url() == url putsok, I stayed at the destination url else putswarning: rewriting or redirection took effect end end [1] http://wtr.rubyforge.org/rdoc/index.html ___ 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] Is there a Watir code snippets database?
Is there a Watir code snippets database? Obviously I've got the watir tests to work with.. but I'm looking for more/different. I learn so much better by example than instruction.. I've been struggling with things I think are basic but which I'm not quite ready to figure out on my own yet.. =) ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
assert_match(mystring,ie.html) I use this all the time. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: I know about contains_text() but is there some sort of contains_html() feature, or should I build my own method to do this? I notice html() which will output the entirety of the HTML for a page, but is there an easy way to match text within that. I mean to ask.. has anyone written a snippet of code which I can re-use? ___ 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] Is there a method to do ie.contains_html() ?
Just a question can one use a Regexp object instead of mystring if one want to do pattern matching in the assert_match? Cheers Pierre Garigue -Original Message- From: Chris McMahon [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 26, 2005 2:13 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] Is there a method to do ie.contains_html() ? assert_match(mystring,ie.html) I use this all the time. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: I know about contains_text() but is there some sort of contains_html() feature, or should I build my own method to do this? I notice html() which will output the entirety of the HTML for a page, but is there an easy way to match text within that. I mean to ask.. has anyone written a snippet of code which I can re-use? ___ 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 mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
On 10/26/05, Chris McMahon [EMAIL PROTECTED] wrote: assert_match(mystring,ie.html) Could you wrap this up in a bit of code for me? I don't understand how to use it. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
how about this? def test_something begin ie.goto(some_url) assert_match(mystring,ie.html) @@log.info PASS rescue = e @@log.info FAIL end end this is off the top of my head, would this work? -Pierre -Original Message- From: Sy Ali [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 26, 2005 3:59 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] Is there a method to do ie.contains_html() ? On 10/26/05, Chris McMahon [EMAIL PROTECTED] wrote: assert_match(mystring,ie.html) Could you wrap this up in a bit of code for me? I don't understand how to use it. ___ 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] Is there a method to do ie.contains_html() ?
Ok, interpreting Pierre's example, I can come up with the code below. However, this always fails. I assume I'm doing something somewhat wrong here, but I don't quite understand what. #-- BEGIN require 'Watir' # the watir controller include Watir # Search for text in the HTML of a page def search_html(string) putssearching the source for + string begin assert_match(string,$ie.html()) putsok -- found + string rescue = e puts FAIL -- could not find + string end end $ie = Watir::IE.start(http://example.com;) search_html(.) # END ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
IT's a LOT easier than that ... just add class Watir::IE def contains_html( input ) html.scan( input ) != [] end end after you do your require... now it *does* have a contains_html function. assert $ie.contains_html blah or assert $ie.contains_html /blah/ hope that helps. j. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: Ok, interpreting Pierre's example, I can come up with the code below.However, this always fails.I assume I'm doing something somewhat wrong here, but I don't quite understand what.#-- BEGINrequire 'Watir' # the watir controllerinclude Watir# Search for text in the HTML of a pagedef search_html(string) puts searching the source for + string begin assert_match(string,$ie.html()) puts ok -- found + string rescue = e puts FAIL -- could not find + string endend$ie = Watir::IE.start(http://example.com)search_html(.)# END___ Wtr-general mailing listWtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general -- http://ruby-lang.org -- do you ruby?Jeff Wood ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
Jeff, does that mean that I do this? : require 'Watir' # the watir controller include Watir class Watir::IE def search_html( input ) html.scan( input ) != [] end end def search_html(string) putssearching the source for + string begin assert_match($ie.contains_html,string) putsok -- found + string rescue = e puts FAIL -- could not find + string end end $ie = Watir::IE.start(http://example.com;) search_html(.) Because this also fails.. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: Jeff, does that mean that I do this? : require 'Watir' # the watir controller include Watir class Watir::IE def search_html( input ) html.scan( input ) != [] end end def search_html(string) putssearching the source for + string begin assert_match($ie.contains_html,string) putsok -- found + string rescue = e puts FAIL -- could not find + string end end $ie = Watir::IE.start(http://example.com;) search_html(.) Because this also fails.. Blah, now I know that's wrong.. I think I'm going to take a break... ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
There are two problems ... #1 you can't use the assert functions unless you are building a TestCase object... #2 you don't need the search_html function. just require 'watir' include Watir class Watir::IE def contains_html( input ) html.scan( input ) != [] end end $ie = IE.new $ie.goto http://example.com $ie.contains_html( . ) should return a true or false. so you could do if $ie.contains_html . puts Has html else puts Doesn't have html end ... that's all there is to it... My code was meant as an alternative ... but any function that people send to you that contains assert won't work without additional libraries being required. Let me know if my example doesn't work for you. j. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: Jeff, does that mean that I do this? :require 'Watir' # the watir controllerinclude Watir class Watir::IEdef search_html( input ) html.scan( input ) != []endenddef search_html(string) puts searching the source for + string begin assert_match($ie.contains_html,string) puts ok -- found + string rescue = e puts FAIL -- could not find + string endend$ie = Watir::IE.start( http://example.com)search_html(.)Because this also fails..___Wtr-general mailing list Wtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general-- http://ruby-lang.org -- do you ruby?Jeff Wood ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
Well, when you get back let me know ... always glad to help. j. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: Jeff, does that mean that I do this? : require 'Watir' # the watir controller include Watir class Watir::IE def search_html( input ) html.scan( input ) != [] end end def search_html(string) puts searching the source for + string begin assert_match($ie.contains_html,string) puts ok -- found + string rescue = e puts FAIL -- could not find + string end end $ie = Watir::IE.start( http://example.com) search_html(.) Because this also fails..Blah, now I know that's wrong.. I think I'm going to take a break...___ Wtr-general mailing listWtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general -- http://ruby-lang.org -- do you ruby?Jeff Wood ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Intermittent bug setting radio buttons with high index values
I have an HTML page with a large number of radio buttons that I address by index. Sometimes my script succeeds, but more often I'm getting error messages Watir::Exception::UnknownObjectException: Unable to locate object, using index and 17 (or 16, or 20, or 19) Has anyone else seen this behavior? -Chris ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
thank for metioning that Jeff, I forget that the assert functions are part of TestCase. an interesting read for that is: http://wiki.rubyonrails.com/rails/pages/HowtoUnitTest and it states ---quote-- The Hierarchy Theres a hierarchy involved with unit tests. It starts at an individual assertion (more later), and ends at a suite (more later). Bottom up, it looks like this: assertion belongs to a test which belongs to a test case which belongs to a test suite end quote Jeff Wood wrote: There are two problems ... #1 you can't use the assert functions unless you are building a TestCase object... #2 you don't need the search_html function. just require 'watir' include Watir class Watir::IE def contains_html( input ) html.scan( input ) != [] end end $ie = IE.new $ie.goto http://example.com $ie.contains_html( "." ) should return a true or false. so you could do if $ie.contains_html "." puts "Has html" else puts "Doesn't have html" end ... that's all there is to it... My code was meant as an alternative ... but any function that people send to you that contains assert won't work without additional libraries being required. Let me know if my example doesn't work for you. j. On 10/26/05, Sy Ali [EMAIL PROTECTED] wrote: Jeff, does that mean that I do this? : require 'Watir' # the watir controller include Watir class Watir::IE def search_html( input ) html.scan( input ) != [] end end def search_html(string) puts " searching the source for " + string begin assert_match($ie.contains_html,string) puts " ok -- found " + string rescue = e puts "FAIL -- could not find " + string end end $ie = Watir::IE.start(" http://example.com") search_html(".") Because this also fails.. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general -- " http://ruby-lang.org -- do you ruby?" Jeff Wood ___ 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] Firefox browser testing tool
Saw this on agile-testing list: http://developer.spikesource.com/wiki/index.php/Projects:TestGen4Web -- Chris http://clabs.org/blogki ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a Watir code snippets database?
At 12:47 PM 10/26/2005, Sy Ali wrote: Is there a Watir code snippets database? 1. The unit tests for Watir. 2. The mail archives for Watir. 3. The watir tests for instiki. 4. The scripting101 solutions. _ Bret Pettichord www.pettichord.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is there a method to do ie.contains_html() ?
At 04:05 PM 10/26/2005, Sy Ali wrote: $ie = Watir::IE.start(http://example.com;) search_html(.) Because this also fails.. Try $ie.search_html(.) instead. Sy, note that you would probably benefit from just learning more Ruby. It's not the Watir code that is tripping you up, but rather the Ruby syntax. There are many excellent books about Ruby. Bret _ Bret Pettichord www.pettichord.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] getting the HTTP status
At 12:29 PM 10/26/2005, Sy Ali wrote: On 10/21/05, Pierre Garigue [EMAIL PROTECTED] wrote: I because I 'rescue' everything, getting a 500 or 404 would just give me a fail. I would like to add info to the log that is failed and got this http status. I too am using the basic rescue technique, which doesn't really give me a whole lot to work with. I read through the technical docs[1] and couldn't find anything more specific. Perhaps this feature does not exist? The rescue technique was documented in old versions of the Watir documentation. It is a bad idea and had been removed from the version currently posted to the website. Strictly speaking, this was never a Watir feature. Rather, rescue is a Ruby feature, which doesn't really help with what you are doing here. I wonder what would happen if I turned on friendly error messages .. then if rescue catches the error, could I scan the page or title to determine the nature of the error? Here is my go to method, used with goto(http://example.org/foo/bar.html;) or goto(variable). It's different than yours because it notices succesfully-loaded, but redirected pages: def goto(url) begin puts * going to + url $ie.goto(url) rescue puts ERROR else putsok, destination loads end if $ie.url() == url putsok, I stayed at the destination url else putswarning: rewriting or redirection took effect end end [1] http://wtr.rubyforge.org/rdoc/index.html The fundamental problem is that an error at the http-protocol level (like a 404) is not a Watir error. It won't raise an exception. Why? Because from a user level (which is the level that Watir works at) there is no error. The browser shows a page -- maybe it is a 404 page. You will have to add code to check to see if you got a page that was different from what you expected. Sometimes a 404 is what is supposed to happen. _ Bret Pettichord www.pettichord.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] getting the HTTP status
At 12:45 PM 10/26/2005, Pierre Garigue wrote: I'm not sure the way below is better, here is a fragment begin assert_nothing_raised(){ (@@ie.link(:text, link_name).click) } @@log.info PASS: got down to #{link_name} rescue = e @@log.info FAIL: did not get to #{link_name} end Rather, I suggest: begin @@ie.link(:text, link_name).click @@log.info PASS: got down to #{link_name} rescue @@log.info FAIL: did not get to #{link_name} end The use of an assertion (namely, assert_nothing_raised) adds nothing. _ Bret Pettichord www.pettichord.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] getting the exception value
At 10:37 AM 10/24/2005, Pierre Garigue wrote: Watir::Exception::NavigationException This exception is thrown if an http error, such as a 404, 500 etc is encountered while navigating Does anyone have an example where this is used? I would also very much like to be able to know if it was a 404 or a 500 for my logs. Ah! Now i remember. This looks like some code that Paul and I paired on. I only understand about half of it. I suspect he feels the same way, but with the other half. I don't think we quite finished it. You can look at navigate_test.rb to learn a bit about it, but i suspect that to make good use of it, you'll have to finish where we left off. The code is kind of hairy... Bret _ Bret Pettichord www.pettichord.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general