Re: [Wtr-general] OT: find min/max values in an array of floats
Neat. I guess I should have just written the code and tried it out. On 5/8/07, Bret Pettichord [EMAIL PROTECTED] wrote: Chris McMahon wrote: I can think of a couple of ways to do this, but they're all painful in one way or another. Ruby being Ruby, I wonder if there's some nifty shortcut. Given floats = [] floats 3.456 floats 1.53 floats 5.123 show that the least element of the array is 1.53 and the greatest element of the array is 5.123, where the array floats can have an arbitrarily large number of elements, of which all are (of course) numbers with decimal values irb(main):001:0 floats = [] = [] irb(main):002:0 floats 3.456 = [3.456] irb(main):003:0 floats 1.53 = [3.456, 1.53] irb(main):004:0 floats 5.123 = [3.456, 1.53, 5.123] irb(main):005:0 floats.min = 1.53 irb(main):006:0 floats.max = 5.123 These methods aren't simply part of the Array class. Rather they come from the Enumerable module (which Array uses). You can mix this module into any of your classes that implements two methods: each and the comparison operator (aka spaceship) that looks like this: = and thereby automatically get cool methods like this. You can also extend any objects that support these methods with the Enumerable method. I often do this with win32ole objects that implements the (COM) IEnumerable interface and therefore have an each method. Bret ___ 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] OT: find min/max values in an array of floats
Chris McMahon wrote: I can think of a couple of ways to do this, but they're all painful in one way or another. Ruby being Ruby, I wonder if there's some nifty shortcut. Given floats = [] floats 3.456 floats 1.53 floats 5.123 show that the least element of the array is 1.53 and the greatest element of the array is 5.123, where the array floats can have an arbitrarily large number of elements, of which all are (of course) numbers with decimal values irb(main):001:0 floats = [] = [] irb(main):002:0 floats 3.456 = [3.456] irb(main):003:0 floats 1.53 = [3.456, 1.53] irb(main):004:0 floats 5.123 = [3.456, 1.53, 5.123] irb(main):005:0 floats.min = 1.53 irb(main):006:0 floats.max = 5.123 These methods aren't simply part of the Array class. Rather they come from the Enumerable module (which Array uses). You can mix this module into any of your classes that implements two methods: each and the comparison operator (aka spaceship) that looks like this: = and thereby automatically get cool methods like this. You can also extend any objects that support these methods with the Enumerable method. I often do this with win32ole objects that implements the (COM) IEnumerable interface and therefore have an each method. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] FireWater: click on link should launch new page/tab, but does not
Close enough. It seems like when you do Apple-R in TextMate, TextMate doesn't capture stderr, only stdout. When I ran the script from IRB, I got irb(main):020:0 ff.link(:src, /help/index.cgi?socialtext_documentation).click FireWatir::Exception::UnknownObjectException: Unable to locate object, using src and /help/index.cgi?socialtext_documentation from /usr/local/lib/ruby/gems/1.8/gems/firewatir-1.0.2/./MozillaBaseElement.rb:881:in `assert_exists' from /usr/local/lib/ruby/gems/1.8/gems/firewatir-1.0.2/./MozillaBaseElement.rb:1027:in `click' from (irb):20 However, I was able to click the link and get the new page with ff.link(:text, Help).click So that's FireWater 1, Selenium 0. :) On 5/8/07, Chris McMahon [EMAIL PROTECTED] wrote: I was able to click on the help link which opened in new window. Currently you can connect to only new window not new tab. Make sure you have allowed popups for that site. I got error that Firefox prevented from opening a pop up from the site. When I allowed pop ups I was able to click on the link which opened in new window. Strange. I have Preferences/Tabs set so that New pages should be opened in a new window and Preferences/Content set to not block popups, but the script runs without error from either FireWatir or Firefox. Thanks for checking, it must be something in my environment preventing that new window. I'll keep looking. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] FireWatir: test/unit assertions can't be found?
This is odd: require 'rubygems' require 'firewatir' require 'test/unit' require 'firewatir/testUnitAddons' include FireWatir ff = FireWatir::Firefox.new() ff.goto(http://www.socialtext.net/stoss/index.cgi?mcmahon_test;) ff.link(:text, Help).click sleep 5 ff.attach(:title, /Documentation/) assert_match(Help Table of Contents,ff.text) yields test.rb:13: undefined method `assert_match' for main:Object (NoMethodError) I've tried plain 'assert' also with the same result. I've got Ruby 1.8.6 installed in /usr/local (OSX), and I've removed the default ruby from my env. Why would the assert methods from 'test/unit' not be findable? The code exists in /usr/local/lib/ruby/1.8/test/unit/assertions.rb $ which ruby /usr/local/bin/ruby $ ruby -v ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1] ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] RDOC - Help determining what needs documentation
Jeff Fry wrote: I'm left hoping we can find another way for me to learn what's been added but not documented in v1.5. So Brett, Charley, Paul, or others involved in building v1.5...if you were going to update the rdoc, how would you know what to edit? If you were going to be making the edits yourself, what parts are most time consuming for you? Would it be worth your time come up with a rough list of things that need documentation and pass that to someone else to document? Or does generating that list constitute the bulk of the work, after which there's not much point in delegating the writing? Alternately, is there a way that you could teach me to generate that list of things that needs documenting? In my view, the purpose of the rdoc is to provide detailed documentation of methods and classes. To the degree that we need good overview documentation (which we certainly do need), to me it is open question whether you put that in a users guide separate from the rdoc or in the header of the rdoc. Right now, the main file is pretty bad. It pulls in a todo list and yet omits the version number. So there are a lot of rather obvious changes that need to be made. Obvious to me at least, but i think that any one who looks at other well-documented Ruby packages (Rspec is another good example) will come to some quick conclusions. One specific example - how can I determine what methods can take :class as a parameter? I know that this works for button, text_field and div...but is there a way I can find out what other methods take :class via searching source code in eclipse? I just tried reading searching watir.rb for clues...but I got lost. Excellent question. I suggest that you focus on questions like this and then help us figure out the best way to document the answers. To me it is unclear whether it would be better to try and get the rdocs to include this information, or whether it would simply be easier to create a big table in the wiki. Please do what you think is easiest and clearest. Now to answer your question. First of all, the how symbols that you can use to specify an element actually directly correspond to the zero-argument methods for the Element class. (This relationship is new to Watir 1.5 -- it was much more hard-coded in 1.4). If you look at the Element class, you will see that it supports the class_name method. That means you do ie.button(:class_name, 'foo') to specify a particular button by class. The reason this method isn't just class is because that is a reserved method name in Ruby. But what we did is provide a direct (hard-coded) mapping from the :class symbol to the class_name method in the locator method. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] RDOC - Help determining what needs documentation
Paul Rogers wrote: In my opionion, the rdocs are really dificult to read right now. I think if I was picking up watir now and looking at the rdocs for the first time, Id be a bit disheartened. I would make sure that only relevant ( to the end user ) methods/classes/modules are in the rdoc you can switch off rdoc like this #-- # I dont get documented def foo end #++ there are lots of methods that really dont help the user as far as documenting them, eg element_tag ( Watir::xxx ) and the methods that people would care about ( click , set etc ) are kind of hidden. To me there are three important profiles of users of the Rdoc: 1. Testers who are new to Watir and to Ruby and who need to know what methods and arguments are available. (These are the people who i think you are referring to as end users). A particular challenge for these users is that they may not have experience reading Rdocs and therefore need to have many of the rdoc conventions explained that other Ruby libraries don't bother with. One example of this is that the IE class includes the Container module and therefore many of the methods available are not in the rdocs for IE, but rather for Container. Experienced Ruby programmers will be able to find this in the rdocs without trouble. Another example is whether the doc for IE#button should indicate that the method returns an instance of the Button class (with a link to the Rdoc for that class)? I don't think we did this for Watir 1.4, but doing this might actually make it so that the methods people care about aren't hidden. But it means that they need to understand a little more about how Watir works. 2. Ruby programmers who know how to read Rdocs and understand object-oriented programming. In particular, i am reluctant to say that we should only document methods and classes that the users in the first profile are interested in, because these people will appreciate more detailed information. 3. Library developers. In particular i think of the WET developers and the FireWatir/SafariWatir developers. We need to provide extension API's to allow Watir classes to be used, sometimes selectively by these other libraries. This means giving some attention to what the extension API's are and marking which are published and stable and which should not be used (private, or practically so). Again, not documenting any of these does not sound like a great idea. It is possible to specify which classes you want to generate RDOC for. One possibility would be to build a set of rdoc output (html) for the tester-user and then build another, more comprehensive collection for the serious developer. Id maybe also try to minimize the usage of the method descrioptions by making a really good intro section ( see the rails docs, especially ActiveRecord::Base ( http://api.rubyonrails.org/classes/ActiveRecord/Base.html ) If you do a good intro maybe broken into 1- what watir is, ( license etc ) 2 - finding objects using irb - using show_xx abd xx.show methods, flash, to_s Personally, i no longer tell people to use the show_methods. Instead, i tell them to use the Dom Explorer. In fact, we have a number of reported bugs with the show methods, no unit tests for them, and no one seems to be maintaining them. I am considering removing them from Watir 1.6. (I haven't decided yet.) 3 - finding objects using :index, :value :class etc One of the problems with the existing doc is that this information is repeated in too many places, and therefore has not been updated in too many places. 4 - methods particular to several objects ( with links to the full list of methods ) like ie.link(:id, 'x').click ie.button(:name , 'y').value At moment i am thinking that the doc for IE#link should point to the Link class and that the Link class should provide a summary of the most popular methods (as well as the detailed list which is automatically generated.) Another idea would be steal from the watir cheat sheet. http://secretgeek.net/watir_cheatsheet.asp Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Community involvement with Watir
2007/5/5, Željko Filipin [EMAIL PROTECTED]: On 5/5/07, Bret Pettichord [EMAIL PROTECTED] wrote: I think i convinced Zeljko today to take the lead in updating the users guide. You certainly did. Last night I had a dream how I bribed cartoon foxes from why's (poignant) guide to ruby to switch to Watir user guide. :) ( Bret encouraged me to be bold.) Zeljko, how can we all help you? The usual. Suggestions. What to add, what to remove, what to change. Comments on my changes. They will be bold. Bacon. Those foxes demanded lots of bacon. I think a section of recipes, where people could post clear and well commented code on how to do specific tasks, would also be very useful, perhaps even some non-testing stuff like automating airline ticket searching or emptying large gmail labels. It could start with finding stuff in dzone snippets and/or asking for submissions on the list/website. Cheers, Helder Zeljko -- ZeljkoFilipin.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general -- Then there were the lonely few of us who moved back and forth on the strip, eating rows of beads here and there, pretending we were Turing machines. -- xkcd : http://xkcd.com/c205.html ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Community involvement with Watir
Helder Ribeiro wrote: I think a section of recipes, where people could post clear and well commented code on how to do specific tasks, would also be very useful, perhaps even some non-testing stuff like automating airline ticket searching or emptying large gmail labels. It could start with finding stuff in dzone snippets and/or asking for submissions on the list/website. Just to be clear, we have always been open to having people add these to our wiki and have often encouraged this. http://wiki.openqa.org/display/WTR/Contributions Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir + Autoit + Save As
Ok, But I don't want just to save the html code... When I click on a button, that open a windows popup (a 'save as' window) that I use to save a file to the HDD. I tried this but it doesn't work : ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] FireWatir: test/unit assertions can't be found?
include Test::Unit::Assertions # you need to mix in the assertion methods if you want to use them outside of a testcase. Thanks, got it, I should have seen that. -C ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Ataaching to windows on slow network connections
Time and again I have faced issues where the WATIR attach method, that returns a handle to a popup window, has misbehaved. Specifically I have noticed this on somewhat slow connections. In Cases where the pop up windows take some time to get rendered on the client machine, the attach method throws an exception saying that it coud not find the window. I have been using WATIR 1.4.x extensively for my projects. I came up with this small solution that would grab the window no matter how slow the connection is. Can someone think of a better way to do it, or does this solution look viable? def GTools.waitForPopUp(ie, title) iePopUp = '' popupGrabber = false popupGrabberCounter = 0 #I'll wait for the popup to come up... I'll make some iterations and then I'll stop iterating #Ideally the number of iterations to be made should be made configurable (number 21) while(popupGrabber == false popupGrabberCounter = 21) begin rxp = Regexp.new(title) iePopUp = Watir::IE.attach(:title, rxp) # I will reach this point only if attach does not throw an exception popupGrabber = true rescue Exception = ex # If the code reaches this block it means that the pop up window that # u were trying to grab using attach was not served up by the WebServer # set the Grabber flag to false and return back into the loop print Rescued Exception\n popupGrabber = false end popupGrabberCounter = popupGrabberCounter + 1 if(popupGrabberCounter = 21) raise GUIException(PopUp Timeout No PopUp Window having title + title + was found) end return iePopUp end When I use this workaround method I have noticed that the code enters the rescue block quite anumber of times before it attaches successfully to the window. I am eager to know if there is a better way to do this? -- Dhruv ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Community involvement with Watir
On 5/8/07, Bret Pettichord [EMAIL PROTECTED] wrote: I think one question Zeljko needs to address is what form he wants it to be. I think he said something about breaking it into separate files, which is fine. Another option is to migrate it to the wiki, which would make eat easier to get contributions from others... I have been thinking a lot about updating Watir user guidehttp://wtr.rubyforge.org/watir_user_guide.htmlthese days, but I did not have time to start working. I will have some time next week (if not before). I think if user guide is migrated to Watir Wikihttp://wiki.openqa.org/display/WTR/Project+Homeit would make contributions much easier, so I plan to do that. If anybody would like to start working on user guide before I migrate it to Wiki, go ahead and grab it from Watir SVN http://svn.openqa.org/svn/watirrepository, make Wiki page and start working. If you do not know how to get it from SVN repository http://www.openqa.org/watir/cvs.action or how to create Wiki pagehttp://wiki.openqa.org/display/WTR/Contributing+to+this+Website, please let me know. I received a lot of good advice about updating user guide. There is a clear need for more documentation on Watir. I do not think that everything should be in user guide. My plan is to make user guide as short as possible and provide links to more advanced topics. Something like: - Install Ruby. - Install Watir. - Open IE. - Navigate to a page. - Click a link. - Click a button. - Verify some text is there. - That was easy! - Want to learn more? - See how you can work with: - Other tags. - Various pop-up windows. - JavaScript. - AJAX. - Unit tests (running them, reading them, learning from them). - … - There is also lots of good documentation on Watir that *is* at our site. See: - FAQ - What is Ruby? - What is Watir? - Is there a difference? - Why should I care? - … - There is also lots of good documentation on Watir that *is not* at our site. Check it out: - Articles. - Cheat sheets. - Books. - … - Have question? We have mailing list! When posting a question make sure that you include: - Relevant snippet of your Watir code. - Relevant snippet your HTML. - Error message that Ruby gave you (if any). - See example question. I think this short tips about posting to mailing list are very important. I just hope people will read it. I think we are ready for several Watir tutorials (at least two). Take Ruby for example. It has Pickaxehttp://www.pragmaticprogrammer.com/titles/ruby/index.htmlbook that you can have on your desk and not be embarrassed when you boss takes a look at it. There is also Why's (Poignant) Guide to Rubyhttp://poignantguide.net/ruby/. I remember how my boss was surprised when he saw Why's book. I am sure he thought I was joking when I told him that it is a book about programming. (Hint: cartoon foxes shouting Chunky bacon!.) Watir user guide can have enterprise look, but I would also like to create one version with cartoon characters. I am sure there are lots of creative people here and I hope they will show their creativity. If you would not like to see cartoon characters in Watir user guide, please do let me know, I will not put it at Watir Wiki. (I will put it at my blog and smile to my jokes. Alone.) Zeljko -- ZeljkoFilipin.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Having trouble capturing text in java alert
Hi everyone, I'm having difficulty in capturing the text from a java alert, and would appreciate anyones input. Using AutoIT, for the pop up window works a treat, allowing me to capture the text, and then select the OK button to proceed with the script: require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' class TC_recorded Test::Unit::TestCase def check_for_popups autoit = WIN32OLE.new('AutoItX3.Control') loop do sleep(3) ret = autoit.WinWait('Security Information', '', 1) text = autoit.WinGetText('Security Information', '') if (ret==1) puts text else puts where is it? end if (ret==1) then autoit.Send('{Yes}') end sleep(2) end end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(http://hmvdigital.co.uk/HMV.Digital.OnlineStore.Portal/Pages/Home.aspx;) @IE0.link(:text, Sign in).click @popup = Thread.new { check_for_popups } # start popup handler @IE0.link(:href, https://hmvdigital.co.uk/HMV.Digital.OnlineStore.Portal/Pages/HelpPopup.aspx?category=Managing_your_accountlink=AboutRememberMe;).click Thread.kill(@popup) # end popup handler @IE0.close end end Unfortunately I have been unable to use AutoIt in dealing with an alerts, and have been using winClicker. I am able to select the OK button to proceed, but unable to capture any text: require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' require 'watir/winClicker' class TC_recorded Test::Unit::TestCase def startClicker( button , waitTime = 3) w = WinClicker.new longName = @IE0.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName }\\watir\\clickJSDialog.rb #{button } #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(www.hmv.co.uk) @IE0.link(:text, Sign In).click startClicker(OK , 3) @IE0.image(:alt, continue).click @IE0.close end end As previously mentioned, any help would be greatly appreciated, many thanks ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Ataaching to windows on slow network connections
Untested, but this will try to attach every two seconds forever: def get_popup begin ie.attach(:title, My Window) rescue sleep 2 get_popup end end ## You could put your counter in there with an exit clause. On 5/9/07, Dhrubojyoti Biswas [EMAIL PROTECTED] wrote: Time and again I have faced issues where the WATIR attach method, that returns a handle to a popup window, has misbehaved. Specifically I have noticed this on somewhat slow connections. In Cases where the pop up windows take some time to get rendered on the client machine, the attach method throws an exception saying that it coud not find the window. I have been using WATIR 1.4.x extensively for my projects. I came up with this small solution that would grab the window no matter how slow the connection is. Can someone think of a better way to do it, or does this solution look viable? def GTools.waitForPopUp(ie, title) iePopUp = '' popupGrabber = false popupGrabberCounter = 0 #I'll wait for the popup to come up... I'll make some iterations and then I'll stop iterating #Ideally the number of iterations to be made should be made configurable (number 21) while(popupGrabber == false popupGrabberCounter = 21) begin rxp = Regexp.new (title) iePopUp = Watir::IE.attach(:title, rxp) # I will reach this point only if attach does not throw an exception popupGrabber = true rescue Exception = ex # If the code reaches this block it means that the pop up window that # u were trying to grab using attach was not served up by the WebServer # set the Grabber flag to false and return back into the loop print Rescued Exception\n popupGrabber = false end popupGrabberCounter = popupGrabberCounter + 1 if(popupGrabberCounter = 21) raise GUIException(PopUp Timeout No PopUp Window having title + title + was found) end return iePopUp end When I use this workaround method I have noticed that the code enters the rescue block quite anumber of times before it attaches successfully to the window. I am eager to know if there is a better way to do this? -- Dhruv ___ 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] Having trouble capturing text in java alert
w = WinClicker.new text = w.get_static_text('Microsoft Internet Explorer') # returns an array for each static control text.each {|t| puts t} -Charley On 5/9/07, gary [EMAIL PROTECTED] wrote: Hi everyone, I'm having difficulty in capturing the text from a java alert, and would appreciate anyones input. Using AutoIT, for the pop up window works a treat, allowing me to capture the text, and then select the OK button to proceed with the script: require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' class TC_recorded Test::Unit::TestCase def check_for_popups autoit = WIN32OLE.new('AutoItX3.Control') loop do sleep(3) ret = autoit.WinWait('Security Information', '', 1) text = autoit.WinGetText('Security Information', '') if (ret==1) puts text else puts where is it? end if (ret==1) then autoit.Send('{Yes}') end sleep(2) end end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto( http://hmvdigital.co.uk/HMV.Digital.OnlineStore.Portal/Pages/Home.aspx;) @IE0.link(:text, Sign in).click @popup = Thread.new { check_for_popups } # start popup handler @IE0.link(:href, https://hmvdigital.co.uk/HMV.Digital.OnlineStore.Portal/Pages/HelpPopup.aspx?category=Managing_your_accountlink=AboutRememberMe ).click Thread.kill(@popup) # end popup handler @IE0.close end end Unfortunately I have been unable to use AutoIt in dealing with an alerts, and have been using winClicker. I am able to select the OK button to proceed, but unable to capture any text: require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' require 'watir/winClicker' class TC_recorded Test::Unit::TestCase def startClicker( button , waitTime = 3) w = WinClicker.new longName = @IE0.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName }\\watir\\clickJSDialog.rb #{button } #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(www.hmv.co.uk) @IE0.link(:text, Sign In).click startClicker(OK , 3) @IE0.image(:alt, continue).click @IE0.close end end As previously mentioned, any help would be greatly appreciated, many thanks ___ 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] The Plan for Watir
Thanks for your detailed replies. Comments inline. Christopher Rasch wrote: Well, ultimately, I want to be able to handle any popup that the browser throws up: attach to it, manipulate it, etc. My understanding is that better modal dialog support is one of the new features of Watir 1.5. See here: http://wiki.openqa.org/display/WTR/Watir+1.5+Summary Right. We added support for handling the IE-specific showModalDialog() in Watir 1.5. As Chris said, there is a terminology problem. Technically, any dialog that blocks access to the main page while it is posted is modal. There are many technologies that allow this. 1. Javascript alert() and confirm() 2. The showModalDialog() mentioned above 3. Various security and authentication dialogs 4. File dialogs such as save as. 5. More recently, there are ajax modal dialogs that appear within the page. Watir 1.5 supports the modal_dialog command which supports #2 above. A good argument could be made that it needs to have a more-specific name. And here: Deliver new DLL that allows us to access DOM embedded in modal web dialogs http://jira.openqa.org/browse/WTR-14 WIN32OLE patch for Modal Web Dialog Support http://jira.openqa.org/browse/WTR-2 Both of these tickets relate to improving the existing modal web dialog support (showModalDialog). At this point, I no longer have plans to work on them and no one else has volunteered to work on them. Probably the biggest problem with our current support for showModalDialog is that it only works with Ruby 1.8.2. Fixing this would require that IEDialog.dll be rewritten as an activex component. Provide cleaner interface and more reliable support for modal windows dialogs (i.e. replace winClicker.rb) http://jira.openqa.org/browse/WTR-4 Although this is desirable and many people have talked about helping with this, we've seen few actual contributions. Personally, i have almost always found ways to avoid these dialogs, so I have never had much motivation to fix this myself. Since integration of the various watirs is also part of the roadmap, I expect that some of the better modal dialog support will also be migrated to the other watir flavors. Perhaps I have the wrong impression? The show_modal_dialog support in watir 1.5 is specific to IE. So no. It would be handy to have a better windows library for handling general windows dialogs, and if we had that, then it would also help for firefox -- you could use it there too, although I know that Angrez is focussing on features that would not be platform specific. All of the mechanisms that we currently using in Watir (autoit, winclicker, win32api) are windows specific, so known of them would be migrated to other platforms. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Having trouble capturing text in java alert
Thanks for the prompt reply. I added the code but it appears to return a value of 'Google', any ideas? require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' require 'watir/winClicker' class TC_recorded Test::Unit::TestCase def startClicker( button , waitTime = 3) w = WinClicker.new longName = @IE0.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName }\\watir\\clickJSDialog.rb #{button } #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(www.hmv.co.uk) @IE0.link(:text, Sign In).click w = WinClicker.new text = w.get_static_text('Windows Internet Explorer') # returns an array for each static control text.each {|t| puts t} startClicker(OK , 3) @IE0.image(:alt, continue).click @IE0.close end end ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Ataaching to windows on slow network connections
Dhrubojyoti Biswas wrote: I am eager to know if there is a better way to do this? Use Watir 1.5. This problem is fixed there. You can look at the repository on openqa if you want details. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Community involvement with Watir
Željko Filipin wrote: Watir user guide can have enterprise look, but I would also like to create one version with cartoon characters. I am sure there are lots of creative people here and I hope they will show their creativity. If you would not like to see cartoon characters in Watir user guide, please do let me know, I will not put it at Watir Wiki. (I will put it at my blog and smile to my jokes. Alone.) Chunky Bacon! ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Community involvement with Watir
I'm all for a Why style guide. His surreal style sucks more people in than if it was a plain old manual. Maybe a donut eating platypus instead of foxes. :) -c On 5/9/07, Bret Pettichord [EMAIL PROTECTED] wrote: Željko Filipin wrote: Watir user guide can have enterprise look, but I would also like to create one version with cartoon characters. I am sure there are lots of creative people here and I hope they will show their creativity. If you would not like to see cartoon characters in Watir user guide, please do let me know, I will not put it at Watir Wiki. (I will put it at my blog and smile to my jokes. Alone.) Chunky Bacon! ___ 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] Community involvement with Watir
On 09/05/07, Bret Pettichord [EMAIL PROTECTED] wrote: Just to be clear, we have always been open to having people add these to our wiki and have often encouraged this. http://wiki.openqa.org/display/WTR/Contributions Bret I think all these important links should become a footnote on Watir's main page. A page that could link to every major contribution, Watir assets have become too amorphous. Also additional user-guide sugesstions IDE's: Arachno, Eclipse, Emacs Test Frameworks: Data-driven, test DSL's?, object mapping, Test::Unit Test Reports: I have written some XML + XLST = HTML. I will put it on the FAQ's. Aidy ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Sample Training Presentation and Exercises posted on Wiki
In case anyone can re-use them, I've posted a basic Watir training presentation and some associated exercises that I've developed and used a few times to train individuals groups in my company on the basics of Watir. Feel free to re-use, modify and enhance them :). http://wiki.openqa.org/display/WTR/Watir+Training+Presentation+and+Exerc ises -David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Sample Training Presentation and Exercises posted on Wiki
On 5/9/07, Brown, David [EMAIL PROTECTED] wrote: In case anyone can re-use them, I've posted a basic Watir training presentation and some associated exercises that I've developed and used a few times to train individuals groups in my company on the basics of Watir. Feel free to re-use, modify and enhance them :). http://wiki.openqa.org/display/WTR/Watir+Training+Presentation+and+Exerc ises The Scripting101 course could use some enhancement. I'm just sayin'... http://rubyforge.org/frs/?group_id=104 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] how to include external script (.rb) in Watir?
On 5/5/07, Alien Ruby [EMAIL PROTECTED] wrote: How are you guys so helpful ? We get a lot of chunky bacon for every correct answer. :) Zeljko -- ZeljkoFilipin.com ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Sample Training Presentation and Exercises posted on Wiki
Chris McMahon wrote: The Scripting101 course could use some enhancement. I'm just sayin'... http://rubyforge.org/frs/?group_id=104 I am actually in the process of rewriting this using the Depot/Rails test application. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Plan for Watir
Christopher Rasch wrote: Both of these tickets relate to improving the existing modal web dialog support (showModalDialog). At this point, I no longer have plans to work on them and no one else has volunteered to work on them. Probably the biggest problem with our current support for showModalDialog is that it only works with Ruby 1.8.2. Fixing this would require that IEDialog.dll be rewritten as an activex component. Doesn't WET already handle modal dialogs pretty well? Yes, i believe it does. What would be involved in integrating WET's functionality into Watir? Some programming and testing. And apparently more than any one is willing to do. Provide cleaner interface and more reliable support for modal windows dialogs (i.e. replace winClicker.rb) http://jira.openqa.org/browse/WTR-4 Although this is desirable and many people have talked about helping with this, we've seen few actual contributions. Personally, i have almost always found ways to avoid these dialogs, so I have never had much motivation to fix this myself. I would like to help, but I don't feel competent enough yet to do any good. I'd imagine that others probably feel the same way. Perhaps it would help attract more help if there were some tutorials on the architecture of watir? First of all, this code has nothing to do with the architecture of watir. It is basically standalone and separate. Your suggestion seems to assume that I am trying to attract more help. Actually, I'm mostly inclined to remove this code from Watir or else move to a separate contrib project. I think the best way to attract support would be be make it clear that this is abandoned code. For the record, i do not have a good understanding of this code. I've never worked on it. And i don't use it. But if you are able to convince somebody to write up a tutorial on how this code works (or doesn't) then that would be great. Just don't look at me. At one point (like when i opened the jira ticket) i thought i might eventually get around to cleaning up this code. I no longer think this is likely. The show_modal_dialog support in watir 1.5 is specific to IE. So no. It would be handy to have a better windows library for handling general windows dialogs, and if we had that, then it would also help for firefox -- you could use it there too, although I know that Angrez is focussing on features that would not be platform specific. All of the mechanisms that we currently using in Watir (autoit, winclicker, win32api) are windows specific, so known of them would be migrated to other platforms. Is there a design document for what such a library should have? No i don't believe so. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Plan for Watir
Id like the winclicker code to disappear and be replaced by a full windows testing library ( How you getting along with that Chris ? ). Enough people seem to want it. Paul - Original Message - From: Bret Pettichord [EMAIL PROTECTED] Date: Wednesday, May 9, 2007 1:40 pm Subject: Re: [Wtr-general] The Plan for Watir Christopher Rasch wrote: Both of these tickets relate to improving the existing modal web dialog support (showModalDialog). At this point, I no longer have plans to work on them and no one else has volunteered to work on them. Probably the biggest problem with our current support for showModalDialog is that it only works with Ruby 1.8.2. Fixing this would require that IEDialog.dll be rewritten as an activex component. Doesn't WET already handle modal dialogs pretty well? Yes, i believe it does. What would be involved in integrating WET's functionality into Watir? Some programming and testing. And apparently more than any one is willing to do. Provide cleaner interface and more reliable support for modal windows dialogs (i.e. replace winClicker.rb) http://jira.openqa.org/browse/WTR-4 Although this is desirable and many people have talked about helping with this, we've seen few actual contributions. Personally, i have almost always found ways to avoid these dialogs, so I have never had much motivation to fix this myself. I would like to help, but I don't feel competent enough yet to do any good. I'd imagine that others probably feel the same way. Perhaps it would help attract more help if there were some tutorials on the architecture of watir? First of all, this code has nothing to do with the architecture of watir. It is basically standalone and separate. Your suggestion seems to assume that I am trying to attract more help. Actually, I'm mostly inclined to remove this code from Watir or else move to a separate contrib project. I think the best way to attract support would be be make it clear that this is abandoned code. For the record, i do not have a good understanding of this code. I've never worked on it. And i don't use it. But if you are able to convince somebody to write up a tutorial on how this code works (or doesn't) then that would be great. Just don't look at me. At one point (like when i opened the jira ticket) i thought i might eventually get around to cleaning up this code. I no longer think this is likely. The show_modal_dialog support in watir 1.5 is specific to IE. So no. It would be handy to have a better windows library for handling general windows dialogs, and if we had that, then it would also help for firefox -- you could use it there too, although I know that Angrez is focussing on features that would not be platform specific. All of the mechanisms that we currently using in Watir (autoit, winclicker, win32api) are windows specific, so known of them would be migrated to other platforms. Is there a design document for what such a library should have? No i don't believe so. ___ 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] Problem retrieving data from an Ajax page
Hi All, I am new to watir. I am automating a web configuration page wherein I fill the contents with different values and upon running the selection, the result page pops up. However when i do a view source of the result page it doesn't show me the latest result page value however in the view source i see the contents of configuration page. The reason for this is that the result page is Ajax based. My actual aim is to verify the result that appears. How do i do it with page source not bringing up the contents? Appreciate u r help Thanks, Lavanya ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] find min/max values in an array of floats
Message: 4 Date: Tue, 8 May 2007 23:18:00 -0600 From: Chris McMahon [EMAIL PROTECTED] Subject: [Wtr-general] OT: find min/max values in an array of floats To: wtr-general@rubyforge.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1; format=flowed I can think of a couple of ways to do this, but they're all painful in one way or another. Ruby being Ruby, I wonder if there's some nifty shortcut. Given floats = [] floats 3.456 floats 1.53 floats 5.123 show that the least element of the array is 1.53 and the greatest element of the array is 5.123, where the array floats can have an arbitrarily large number of elements, of which all are (of course) numbers with decimal values. floats.sort!.last should get the maximum float value ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Plan for Watir
Paul Rogers wrote: Id like the winclicker code to disappear and be replaced by a full windows testing library ( How you getting along with that Chris ? ). Enough people seem to want it. I think a lot of people would like to see that. I certainly would. But last i looked Chris's project hadn't seen a commit in 18 months. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir Data types exported from excel
I'm running a script to read data from a spreadsheet using the following script # open the spreadsheet and get the values excel = WIN32OLE::new('excel.Application') # define the type of application to connect too workbook = excel.Workbooks.Open('d:\Smoke_Test2.xls') # spreadsheet location worksheet = workbook.Worksheets(1) #get hold of the second worksheet worksheet.Select #bring it to the front -need sometimes to run macros, not for working with a worksheet from ruby range=worksheet.range(a1, bw50) # range of spreadsheet #~ excel['Visible'] = false #make visible, set to false to make invisible again. Don't need it to be visible for script to work the value I am picking out of the spreadsheet is a number using the following ie.text_field (:id,/AccountNumber/).set(spreadsheetdata[:'accountnumber'].to_i) when the script enters data into the field it attempts to enter data as follows .0 (decimal place materialises.) I think ruby changes the format of the number 111 extracted from the spreadsheet from an integer as specified using .to_i to another format (hence the decimal place being displayed in the form field) How can I ensure the format of the data extracted from excel stays as an integer or text, allowing a leading zero as '0111' or '' -- The second half of a man's life is made up of nothing but the habits he has acquired during the first half. - Fyodor Dostoevsky ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Plan for Watir
On 5/9/07, Bret Pettichord [EMAIL PROTECTED] wrote: Paul Rogers wrote: Id like the winclicker code to disappear and be replaced by a full windows testing library ( How you getting along with that Chris ? ). Enough people seem to want it. I think a lot of people would like to see that. I certainly would. But last i looked Chris's project hadn't seen a commit in 18 months. There might still be enough there to work with. This is a port of Perl Win32::GuiTest, btw. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir Data types exported from excel
your code doesnt show where you create spreadsheetdate but if you use either the text or attribute ( i cant remember which, and dont have excel here ) myval = worksheet.range('a2')['value'] # or ['text'] one of these will do the right thing Paul - Original Message - From: Tunde Jinadu To: Wtr-general@rubyforge.org Sent: Wednesday, May 09, 2007 3:01 PM Subject: [Wtr-general] Watir Data types exported from excel I'm running a script to read data from a spreadsheet using the following script # open the spreadsheet and get the values excel = WIN32OLE::new('excel.Application') # define the type of application to connect too workbook = excel.Workbooks.Open('d:\Smoke_Test2.xls') # spreadsheet location worksheet = workbook.Worksheets(1) #get hold of the second worksheet worksheet.Select #bring it to the front -need sometimes to run macros, not for working with a worksheet from ruby range=worksheet.range(a1, bw50) # range of spreadsheet #~ excel['Visible'] = false #make visible, set to false to make invisible again. Don't need it to be visible for script to work the value I am picking out of the spreadsheet is a number using the following ie.text_field(:id,/AccountNumber/).set(spreadsheetdata[:'accountnumber'].to_i) when the script enters data into the field it attempts to enter data as follows .0 (decimal place materialises.) I think ruby changes the format of the number 111 extracted from the spreadsheet from an integer as specified using .to_i to another format (hence the decimal place being displayed in the form field) How can I ensure the format of the data extracted from excel stays as an integer or text, allowing a leading zero as '0111' or '' -- The second half of a man's life is made up of nothing but the habits he has acquired during the first half. - Fyodor Dostoevsky -- ___ 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 handle pop dialouge boxes by clicking on OK button
Hi Shalini, Thank you very much for your response. How ever i couldn't able to resolve my issue with these solutions. 1 soultion : giving error message as 'NoMethodError: undefined method `dir' for nil:NilClass' and not moving to the next line '$ie.button(:name,button responsible for popup)' 2. Solution: Problem is same.. Not handling the popup updated windowhelper.rb file too. Thanks in advance. Regards Vamsi ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Using custom attributes
Hi, With Watir 1.4.1 you can use xpath to access such elements. tr = ie.element_by_xpath(//[EMAIL PROTECTED]'12345']) - Angrez On 5/10/07, Andrew Kuzmin [EMAIL PROTECTED] wrote: Hi All, Is there any way to access an element by a custom attributes value ? In my situation, for our web development we're using 3-rd party grid control, which generates a table with lot of custom attributes for its elements. For example, the code would look like this: tr rowKey=12345td column=column1… Since the rowKey is unique it could be used to uniquly identify the row. IE's devTool displays these custom attributes correctly, however they are not accessible from Watir. Any recommendations ? Could Watir be extended to do this ? Thanks, Andrew ___ 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 handle pop dialouge boxes by clicking on OK button
in second solution have u changed the path:- Thread.new{ system(ruby \c:\\PSC\\jscriptExtraAlert.rb\) } i mean to say jscriptExtraAlert...path.. search this file and specy path there... On 5/10/07, vamsi [EMAIL PROTECTED] wrote: Hi Shalini, Thank you very much for your response. How ever i couldn't able to resolve my issue with these solutions. 1 soultion : giving error message as 'NoMethodError: undefined method `dir' for nil:NilClass' and not moving to the next line '$ie.button(:name,button responsible for popup)' 2. Solution: Problem is same.. Not handling the popup updated windowhelper.rb file too. Thanks in advance. Regards Vamsi ___ 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] Having trouble capturing text in java alert
hi u can use this code.. def start_jsalert_clicker Thread.new{ system(ruby \c:\\PSC\\jscriptExtraAlert.rb\) } #please specify ur path of jscriptExtraAlert end u have to change ur windowhelper.rb file as... def push_alert_button @autoit.WinWait Window Internet Explorer, text = @autoit.WinGetText Window Internet Explorer file = File.open(c:\\test.txt, w) file.puts text puts text.to_s file.close @autoit.Send {ENTER} end after then u can read content of these file..ok... Regards Shalini Gupta On 5/9/07, gary [EMAIL PROTECTED] wrote: Thanks for the prompt reply. I added the code but it appears to return a value of 'Google', any ideas? require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' require 'watir/winClicker' class TC_recorded Test::Unit::TestCase def startClicker( button , waitTime = 3) w = WinClicker.new longName = @IE0.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName }\\watir\\clickJSDialog.rb #{button } #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(www.hmv.co.uk) @IE0.link(:text, Sign In).click w = WinClicker.new text = w.get_static_text('Windows Internet Explorer') # returns an array for each static control text.each {|t| puts t} startClicker(OK , 3) @IE0.image(:alt, continue).click @IE0.close end 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
Re: [Wtr-general] Having trouble capturing text in java alert
once again..use this function start_jsalert_clicker...before the object who is responsible for java alert popup.. On 5/10/07, SHALINI GUPTA [EMAIL PROTECTED] wrote: hi u can use this code.. def start_jsalert_clicker Thread.new{ system(ruby \c:\\PSC\\jscriptExtraAlert.rb\) } #please specify ur path of jscriptExtraAlert end u have to change ur windowhelper.rb file as... def push_alert_button @autoit.WinWait Window Internet Explorer, text = @ autoit.WinGetText Window Internet Explorer file = File.open(c:\\test.txt, w) file.puts text puts text.to_s file.close @autoit.Send {ENTER} end after then u can read content of these file..ok... Regards Shalini Gupta On 5/9/07, gary [EMAIL PROTECTED] wrote: Thanks for the prompt reply. I added the code but it appears to return a value of 'Google', any ideas? require 'watir' # the controller include Watir require 'watir/WindowHelper' require 'test/unit' require 'test/unit/ui/console/testrunner' require 'dl/win32' require 'watir/winClicker' class TC_recorded Test::Unit::TestCase def startClicker( button , waitTime = 3) w = WinClicker.new longName = @IE0.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName }\\watir\\clickJSDialog.rb #{button } #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end def test_1 @IE0 = IE.new @IE0.set_fast_speed @IE0.goto(www.hmv.co.uk) @IE0.link(:text, Sign In).click w = WinClicker.new text = w.get_static_text('Windows Internet Explorer') # returns an array for each static control text.each {|t| puts t} startClicker(OK , 3) @IE0.image(:alt, continue).click @IE0.close end 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