Re: [Wtr-general] OT: anyone know Ruby Facets?
Chris McMahon wrote: > http://facets.rubyforge.org/ > > Looks like some interesting things, I just wondered if anyone here has > experience with it/them? Yes, they're rather cool. A lot of useful stuff, interesting stuff, and well-organised and -written. A lot of stuff that subsumes standard Ruby idioms (e.g. array.at_rand instead of the idiomatic array[rand(array.size)]). It includes a lot of eminently reinventable wheels (e.g. combinations and permutations of arrays). Its Symbol#to_proc is moving into core ruby in version 1.9. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Watir Installer
Harry Chou wrote: > On 5/1/06, Harry Chou <[EMAIL PROTECTED]> wrote: >> I don't think GEM works easily behind Firewall/Proxy. Am I not right? > I know there perhaps are ways to get it working. I am just arguing > that this will prevent people from JUST trying Watir. You can easily download the gem and install it locally. I don't think it should be a deterrent, especially if this info is easily available. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] The Watir Installer
+1 Bret Pettichord wrote: > This is a proposal for packaging Watir 1.5. > > Watir will be distributed as two files. > 1. watir-1.5.0.gem - A gem that can be downloaded and installed locally > or remotely installed over the internet (as always). > 2. watir-bonus.zip - A zip file containing the user guide, the examples, > and notes on where to find the unit tests and API docs (which are > already in the gem). > ... > Please vote on this proposal. The installer is redundant and problematic (viz. conflicts with gem versions). Better one distribution than two. This two-part solution's a good idea. I won't need -bonus; I can use gems' doc server. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [OT] - Gem upgrade?
Raghu Venkataramana wrote: > Dave Burt wrote: >> Use this command to remove all old versions of gems you have installed: >> >> gem cleanup >> >> However, as Bret said, there's no harm in leaving them there. >> > Nope. With two versions(and as time goes by it could be more than two) > of a gem library, the > script sometimes pickups the API from the wrong gem and fails. A normal require should get the most recent version. Often people use require_gem to demand a version of a library that works with that program. require_gem "something", "<=0.6" > The trouble is that every script will have to be changed whenever the > version is changed. The point is that you _don't_ need to change your script, the script just uses the old version of the library. > As of now, I am first doing a gem uninstall -a and then do a > gem install Why not just use "gem cleanup"? Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [OT] - Gem upgrade?
Raghu Venkataramana wrote: > How does one upgrade gems? when I do a gem install on the latest gem, I > find two versions of the same application installed: > > for example, > wet-web (0.5, 0.9) > > I am only left with an option to first uninstall the previous version of > GEM and then installing the new one. Is there a way to specify (while > installing the gem) that only the latest version needs to be kept and > the previous version can be removed? > > Any help is appreciated Use this command to remove all old versions of gems you have installed: gem cleanup However, as Bret said, there's no harm in leaving them there. One of RubyGems's features in fact is the ability to require a certain version of a gem library: require_gem "watir", "1.4" require_gem "watir", ">=1.4" Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] changing watir versions
Jeff Fry wrote: > how does my machine find watir? How does it choose between multiple > installs? Can I tell it explicitly in a script to use a particular > version? It depends on how they were installed, and if RubyGems is in control. I think site_ruby installs take priority over gems. (It's been a while since I looked into it, but RubyGems isn't that complicated, and you can read the RubyGems version of require at ruby\lib\ruby\site_ruby\1.8\rubygems\custom_require.rb.) You can load a specific gem version using "require_gem lib_name, version" - like this: require_gem 'rails', '1.0' Or you can use conditional versions, like ">1.0" or "<1.0". But this is, of course, only if you have the gems installed! Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How can I write in a log file?
Martin Lopez wrote: > *I want to know how can I write in a log file.* > ** > *I need save some exceptions or errors and checks to see them after.* There are a few ways. The simplest is to open a file and write to it like this: logfile = open("filename", "a") logfile.puts "This message will go to the log file." # ... logfile.close Or if you want to use something a bit more advanced, use Logger, that's part of the standard library. The main advantage, I think, is it makes it easy to separate error messages from warnings from debugging info, and it can also rotate logs. http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/index.html Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir 1.5?
Hi Bret, Thanks for your complete and helpful answer. I'll probably grab the dev code when I get a chance. Bret said: > Since moving the code to OpenQA, there are a lot of loose ends to tie > up to explain what is going on. If you see one, it would help a lot if > you could tie it off for us. > > The more help i get with the FAQ and the website, etc, the more time i > have to write ruby code. Are these "loose ends" the same thing as "the FAQ and the website, etc"? Or are they inconsistencies in Watir 1.5's object model? Or something else entirely? How can I help with the FAQ and the website, etc.? Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir 1.5?
Hi Bret and anybody else hacking on the Watir library, What's the status on Watir 1.5? The changes I've heard about include effective ways of handling popups (confirm, alert, modal web dialogs, save-as) and more consistent returning of Watir wrappers rather than straight WIN32OLE handles, and I'm looking forward to the future. Do you have a time-frame in mind for a release? If I go to RubyForge and download stuff from CVS, should I expect problems with any particular areas? Thanks, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Multi IE explorer
Xi Chen wrote: > I have looked at FAQ about invoking separate IE instances using Watir. > However I found it doesn't work. For example I tried to open up 10 > different browser with a textfield in each of them. I tried to write > some text in the text_field. All the text are writen into the textfield > in the last IE. Hi, If you show us your code, we can tell you what's wrong with it, why it's not working. Here's one way you might have gone wrong: $ie = Watir::IE.new $ie.goto "google.com" $ie.text_field(:name, "q").set "1" $ie = Watir::IE.new # <--- same variable, reference to first window lost $ie.goto "google.com" $ie.text_field(:name, "q").set "2" # both end up at google.com.au with "bar" in the text field. This works fine: ie_array = Array.new(3) { Watir::IE.new } # open 3 IE windows ie_array.each_with_index do |ie, i| ie.goto "google.com" ie.text_field(:name, "q").set i end Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Make Watir support Chinese chars
Hi, Bret wrote: > 1. Use Ruby 1.8.3. The version of WIN32OLE included here has new support for > alternate > codesets. > 2. Add the following line to the top of the script: > WIN32OLE.codepage = WIN32OLE::CP_UTF8 That's great news, that WIN32OLE issue was really annoying. > I believe that Dave's advice regards what you need in order to embed Asian > characters in Ruby Scripts themselves. Yes, that's right. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Make Watir support Chinese chars
Hi, Has $KCODE been mentioned yet on this list? > I need to test some of our webproducts and websites in foreign > languages and I'm having problems with testing using Asian > characters (European characters seem ok)... I set the script to look > for specific text like "?x?? ?? ???^?m??" --> (this is > traditional Chinese for 'select "page forward" to continue') -- but it fails > when run... Is there some sort of character setting I need to adjust in > Watir? I have not tried the various possibilities but would it work > better to change the search text to some encoding like Hexadecimal > (\u9078\u53D6 \u300C\u4E0B\u4E00\u6B65\u300D > \u4EE5\u7E7C\u7E8C\u3002) work better? You need to tell Ruby the character set you're using in your script using the KCODE directive. For example, put the following line at the top of your script for UTF-8: $KCODE = 'UTF-8' Other recognised values are "EUC" and "Shift-JIS". You'll still probably run into some issues with regexps and so on, but that should get Ruby to understand your script. I hope this helps. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Recording http request response headers
> The best approach would be to use a logging proxy. Any recommendations out there? Maybe MouseHole could be useful, although it's not designed for quite this purpose. I guess you could add logging fairly easily. http://rubyforge.org/projects/mousehole Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Line no
> Does anybody know weather watir have specific function to go to a specific > line no in the program. Yes, it doesn't. You can get an addon to add goto capability from http://raa.ruby-lang.org/project/ruby-goto/ But you don't want to. There's a better way to do what you want to do, but I don't know what it is specifically unless you say a bit more about what you are trying to accomplish. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [OT] running watir in a VM
Warren Pollans wrote in "[OT] running watir in a VM": > This about installing & running watir - part 2 :-) > > Instead of dual-booting XP and linux, I now realize that I could run > XP, and therefore watir, out of a virtual machine via VMWare under > linux. This would probably be more useful for me since the only reason > for me to have XP is to run watir - I'd use watir more if I didn't have > to reboot to get to it. > > QUESTION: Is anyone using watir in a setup like this? XP installed in > a VM using VMWare under fedora 3 or 4? You will have no problems with that setup - it'll be just like the real thing. >> I'd like to use the latest and greatest version of watir. You can grab that from the "Download tarball" link from the bottom of this page: http://rubyforge.org/cgi-bin/viewcvs.cgi/watir/?cvsroot=wtr >> QUESTION: If I use the development version, can I revert to a more >> stable version if there is a problem? Would it just be a question of >> replacing some modules? Where would I get the development version? >> CAUTION: I know ruby, but I'm barely literate when it comes to >> windows. Unzip the dev version to a separate location in your Windows directory heirarchy. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Big trouble working with Nested While & If loops
Hi, Vishal wrote: > > > Hi, > > I am getting a wierd error, whenever I have a nested loop, I have checked > the length of array data its 1. The error read as below: > > irb(main):208:0> while rec_ctr < data.length > irb(main):209:1> > Display all 375 possibilities? (y or n) > == cwws > ===d > =~ data > ARGF def When you're in IRB with the Readline extension, pressing the Tab key will trigger auto-completion. If you paste code with tabs into an IRB session in a command window, the same. One tab at the start of a line will ask before listing "all 375 possibilities" (Object and Kernel methods); two tabs will list those methods. Try starting irb with the --noreadline parameter: % irb --noreadline Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Can I get away from a warning for overwriting a variable value in a Loop?
Vishal Chavan wrote: > Hi All, > > I wanted to seek your advice for getting off following warning : "warning: > already initialized constant Array_Index" > > I have loop where I change the value of a variable. I get this warning, can > get off from this? Here's the loop I have > > count = 1 > Array_Index = 1 > Actual_array = [20] In Ruby, local variables begin with lower-case letters. If you use upper-case, you have created a constant. You answer is to use "array_index" instead of "Array_Index", etc. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] ... iterating over rows & cells in tables ...
Jeff Wood wrote: > Yeah, I knew I could do it that way , it's just not clean enough for me... Fair enough, and definitely it's worth doing better. I wonder if the HEAD version of watir has all or part of this feature, or whether your solution to this could get merged. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] ... iterating over rows & cells in tables ...
Jeff Wood wrote: > I'm not seeing an easy way to iterate over the rows &| cells in tables ... > > I'm going to look into this and see what I can provide. > > Anybody else have any information or suggestions? I'm not against this being doable in Ruby, but there is the COM interface to the DOM: ie.document.getElementsByTagName("table").each do |table| table.getElementsByTagName("tr").each do |tr| tr.getElementsByTagName("th").each do |th| puts th.innerText end tr.getElementsByTagName("td").each do |td| puts td.innerText end end end Or you can easily get a collection of Watir::Table objects and use those: tables = [] ie.document.getElementsByTagName("table").each do |table| tables << Watir::Table.new(ie, :from_object, table) end tables[4].each{|tr| tr.each {|td| print td.text + "|" }; puts } #=> "Operator|Ext|City| Starflower|8172|San Francisco| Melody|5673|San Pedro| Symphony|3820|Montreal|" Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] screw it, I'm using Perl Fwd: painfully stupid AutoIT question
Bret wrote: > The threading in the Win32 Ruby implementation is distinctly inferior to > Perl's. There, i said it. It's not peculiar to Win32 - Ruby uses "green threads" (implemented using select()) which all run in the same process. People claim some benefit from this ("they work the same on all systems") but I don't see it; I think it's simply inferior to native threading. Now, regarding workarounds, Win32 can't fork, but can popen. You can use that to open a new related process. I did that to make my AutoIt javascript dialog handler work - unless AutoIt opens in a separate process, IE waiting on the dialog will block everything (because it blocks the process, and all threads in it). Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Accessing the text contents in Alert windows
> Hi, > I want to acces the contents of an Alert window or conirm that the Alert > window > has appeared. > Is there a way to access the text contents in an Alert Window?. > How do I know if the Alert window has appeared? See the following post: http://rubyforge.org/pipermail/wtr-general/2005-August/003352.html Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] handling file dialog
B> There is some support for some modal dialogs in 1.4. B> B> It is often awkward, and will be improved in 1.5. There are also some types B> of dialogs (not those mentioned by the OP) that can't be accessed using 1.4. J> Not even using AutoIt ??? J> J> I was under the impression that we could do just about ANYTHING with AutoIt. You can. I showed how you can deal with Open/Save dialogs in this post: http://www.mail-archive.com/wtr-general@rubyforge.org/msg01262.html Earlier, I posted a more complete and easy-to-use solution for dealing with Javascript dialogs (confirms and alerts): http://rubyforge.org/pipermail/wtr-general/2005-August/003352.html A note when doing this stuff: modal dialogs are tricky partly because the Ruby thread will block, and partly because bits of Watir (Watir::Simple is the only bit I've had trouble with) specifically wait until IE is in Ready mode. You might need to override a method like Watir::Simple's wait_for_ie to not wait. Also, different IE versions may assign different titles and text in dialogs, making some of this AutoIt code non-portable, although that hasn't been a problem for me so far. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] handling file dialog
Zeljko Filipin wrote: >I also need that, as far as I know, it is not supported. > They say all modal dialogs will be supported in 1.5 > (http://wtr.rubyforge.org/wiki/wiki.pl?RoadMap) > ... > > [EMAIL PROTECTED] > ... > Hi! Could I ask for an example of handling file dialogs? (open,save,,cancel) > thanks! This stuff can be handled using AutoIt, which is bundled with Watir. There's a thread here from a couple of weeks back with an example: http://www.mail-archive.com/wtr-general%40rubyforge.org/msg01262.html Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] OT: double-quotes and substitution in same string?
Chris: > I think so too. Do we have etiquette in place for msgs. not having to > do with Watir directly? I've been using "OT", but maybe that's not > the best. No need, I think. > I'd go to ruby-talk, but the volume there is just too high. You might consider using the newsgroup comp.lang.ruby instead - it's cross-mirrored with the mailing list. I find it a lot easier to deal with than the flood of emails it represents. Google has an interface here: http://groups.google.com/group/comp.lang.ruby If you have a Gmail account, you can even use that to post. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Perl, Win32::GuiTest (was: About the installation of DBI)
> > ... I'm going to have to > > dig up your Win32::GuiTest posts and have a play, I think, Chris. > > Here ya go! Just BTW, the following code is in an article in next > month's Better Software magazine: > > use Win32::GuiTest qw(FindWindowLike GetWindowText > SetForegroundWindow SendKeys); > system (1, "C:\\ruby\\bin\\ruby.exe C:\\watir\\examples\\Demo.rb"); > while (1) { #INFINITE LOOP > sleep 5; #CHECK FOR NEW WINDOW EVERY 5 SEC > my @windows = FindWindowLike(0, "^Microsoft Internet Explorer" > ); > for (@windows) { > SetForegroundWindow($_); #BRING THE RIGHT WINDOW IN FOCUS > SendKeys("{ENTER}"); > } > } Thanks for the preview, Chris. I'm going to have to check out that library for sure. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] About the installation of DBI
Chris McMahon wrote: > BTW, I guess it's not a big secret, but: I *like* Perl. I'm working > in a culture that's excited about Ruby. And right now I have no need > for Watir. So I could actually do my current work in either Ruby or > Perl, and it's just more funner right now in Ruby. It's also nice to > have Plan B: the moment I run into something Ruby can't do, I'll > happily switch to Perl. Nice to have alternatives... > > Look through the archives and you'll see mention of my handling > Javascript popups with a Perl Win32::GuiTest layer. I still think > that's a valid approach, with all due respect to the Wet and AutoIT > fans. Interesting. I've hardly touched Perl since I started with Ruby. I used to like Perl; I wonder If I can still handle it (Ruby seems to click easier with more complex data structures than simple arrays and hashes.) I'm going to have to dig up your Win32::GuiTest posts and have a play, I think, Chris. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] About the installation of DBI
Hi Walter, > Chris, what is AoAs ? Not a special data type, just arrays of arrays. > At my current site, I use WATiR, but cannot do any DB work in Ruby, > because the DB (DB2 on zOS) doesn't allow ODBC connections. You need to > access certain sys/admin tables to get an ODBC connection, and we don't > have even select rights on those. I cannot get the Ruby DB2 driver to > work on my 'doze box. So, Perl + DBD::DB2. Ruby's DBI does have a DBD for DB2. You can get the "ruby-dbi-all" package with all the DBDs from here: http://sourceforge.net/project/showfiles.php?group_id=43737 The DB2 DBD depends on Ruby/DB2, which you'd have to compile; AFAIK Windows binaries aren't available for download: http://raa.ruby-lang.org/project/ruby-db2 Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Wtr-general Digest, Vol 22, Issue 16
Nishita Acharya asked: > This question may have been dealt with before..but can someone tell me how > i can install auotIt.Am not able to find the exe... As Bret said, the DLL is really most of what you need. although the Info tool is helpful, too. Look it up at http://www.autoitscript.com/autoit3/ > Also i find some ODBC.rb and Oracle.rb progs in ruby...i want to know how > they can be used for db connectivity. These are under the DBI/DBD directory. Here is the documentation for DBI: http://ruby-dbi.rubyforge.org/DBI_SPEC.html http://www.kitebird.com/articles/ruby-dbi.html Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Dave did you update the Ruby-Mysql for mysql4.1.XX
jim asked: > I have to connect the mysql4.1.25 but the Ruby-Mysql just support the > mysql4.0.XX. > Have you updated the Ruby-Mysql to support the mysql4.1.XX Try this advice (from ruby-talk): use mysql-administrator & check the Startup Parameters->Security->Use Old Passwords checkbox restart mysql server try again. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to click the Windows 'Save'buttonwhendownloading a file
Mueller schrieb: > Thanks for the answer. I tried this approach, but the Windows opens and > nothing > happens. the scripts is seems to "wait" for an action but nothing happens. > When I > cancel the script no error is reported in the log file. > > Any Idea why it doesnt work? Do i have to install some additional components? Try typing the script line by line into IRB, see where it stops working. If it's not getting a control or window (perhaps because you have a different version of IE or Windows to me, and the text or controls in the windows are different), you might have to change some of the parameters I'm passing to WindowWait or ControlClick etc. You can download AutoIt from http://www.autoitscript.com/autoit3/downloads.php - get the ZIP, and just pick AU3Info.exe out of it - if you run it, then cause the dialogs to be shown, that will tell you the info you need for your script. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to click the Windows 'Save' button whendownloading a file
Michael Müller gebetenes... > In a script in clicking the download link. Then a Windows window appears > with the button Open, Save and Cancel. I´d like to click the save > button. How can I do that? > > The Next window opening is the window to specify the location to save > the file. How can I set the Path to that window? You can do this stuff with AutoIt: require 'win32ole' autoit = WIN32OLE.new("AutoItX3.Control") autoit.WinWait("File Download", "Do you want to open or save", 3) autoit.ControlClick("File Download", "Do you want to open or save", "&Save") autoit.WinWait("Save As", "Save &in", 3) autoit.ControlSetText("Save As", "Save &in", "Edit1", "path\\filename.ext") autoit.ControlClick("Save As", "Save &in", "&Save") See AutoIt3 reference here: http://www.autoitscript.com/autoit3/docs/functions.htm Note to Bret Pettichord: This is something you'd need to take care of before you remove AutoIt from version 1.5. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Passing args from the command line
Ben Torres wrote: > Can someone show me how I can pass 3 arguments from the command line? I > am trying to be able to type in >>colors.rb red white blue, and watir > reads color1 = red, color2 = white, and color3 = blue. ARGV Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir features
At 07:21 AM 9/12/2005, Atilla Ozgur wrote: watir supports pop-up dialogs, though this support is limited to very simple cases and does not support modal dialogs. Bret responded: We will have support for all types of modal dialogs in Watir 1.5. And I posted code earlier that handles modal dialogs using AutoIt. It's not that hard in 1.4. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I can use the DBI now
That's interesting that you got DBI working with Ruby-Mysql, the pure Ruby MySQL interface. I would like to see that updated for MySQL 4.1 and 5. Cheers, Dave - Original Message - From: jim che To: wtr-general@rubyforge.org Sent: Wednesday, September 07, 2005 3:24 PM Subject: [Wtr-general] I can use the DBI now Hi Dave I can use the DBI now . Thank you for your and other people's help. I found the version of Mysql ,ruby and ruby-mysql must match each other The version of these tools should be Mysql-4.0.25 (for win32) (I first use the 4.1.X and it can't work with mysql-ruby) The ruby should be 1.8.2 for win32 The Ruby-Mysql shoud be 0.2.6 (you should copy the 'mysql.rb' to your rubylibdir) And ruby-dbi-all-0.0.21 ps: I do it under the win32. jim Click here to donate to the Hurricane Katrina relief effort. ___ 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] Error in the DBI
dbh = DBI.connect("dbi:Mysql:test:localhost", "testuser", "testpass") Ah yes, MySQL. You have some options: 1) Use ODBC. connect("dbi:odbc:your_mysql_db_dsn") 2) Get the pure-Ruby MySQL wrapper (I don't think you can use DBI with this, so your code won't be portable to other DBMSes): http://raa.ruby-lang.org/list.rhtml?name=ruby-mysql 3) Build Ruby/MySQL. That's non-trivial, and probably not an option if you're not a C/C++ programmer. By the way, these questions are the kinds of questions you will find better help on general Ruby forums than this one: * mailto:[EMAIL PROTECTED] * news:comp.lang.ruby * http://blade.nagaokaut.ac.jp/ruby/ruby-talk/index.shtml * irc://irc.freenode.net/ruby-talk Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Re:Ruby - database using ActiveRecord, Java integration
I am newbee.I found the DBI is for Linux like system not for win32 . Does the DBI for win32 is exist? I am pretty sure it comes with the One-Click Installer, except that the ADO driver has been left out. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Ruby - database using ActiveRecord, Java integration
...This is how I would recommend accessing a database from Ruby for testing purposes. You can read about DBI here: DBI's more complicated than using an ORM such as ActiveRecord or Lafcadio http://lafcadio.rubyforge.org/tutorial.html ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Ruby - database using ActiveRecord, Java integration
This is a reply to several questions from the last few days on database connectivity. Firstly, ActiveRecord is quite handy for dealing with databases, as long as they don't have multi-column keys and other interesting non-Railsy things like that. Find out how here: http://wiki.rubyonrails.com/rails/show/HowToUseActiveRecordOutsideRails Active Record is available via rubygems: "gem install activerecord". If you need to use ADO (i.e. for a MS SQL Server database), you will also need ADO.rb. You can get it here: http://www.dave.burt.id.au/ruby/dbd-ado.zip Now, that is a DBD (DataBase Driver) for the DBI library (common DataBase Interface), which you can use directly - drivers exist for most popular databases. This is how I would recommend accessing a database from Ruby for testing purposes. You can read about DBI here: http://www.kitebird.com/articles/ruby-dbi.html Now, Java! You can easily interface with Java using JRuby. JRuby isn't a library, it's a separate Ruby interpreter that runs under Java: http://jruby.sourceforge.net/ Then you can do cool stuff like this: http://redhanded.hobix.com/bits/funkedOutJavaRubyAggregator.html Write back if any of this is unclear. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] new installers, autoit
Bret: Guess what? The one-click installer can be used as a command line installer. >watir-1.4.1.exe /S ... I do like the idea of a separate script for uninstalling old versions of Watir. You can't register the AutoIt DLL with the RubyGems, can you? That's another plus for the one-click installer. Do you see AutoIt remaining as part of the Watir distribution, or being replaced by Watir popup-handling methods that just use COM? Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How do you invoke autoIt from a Watir script ?
Mike asked: How do you invoke autoIt from a Watir script ? (I am basically interested in getting to left & right mouseclicks, I assume you can't do mouse clicks with send_keys) All the AutoIt documentation is for VB Script. # I got this to run at least, not sure if its right : class Autoit def initialize(libname) end end $autoit=Autoit.new("AutoItX3.Control") # but I can't get this to work later on in the script $autoIt.MouseClick "left" # I must be missing something, or may be making it too complicated. # It gets : myscript.rb:58: undefined method `MouseClick' for nil:NilClass (NoMethodError) Tom's right, $autoit is a different variable from $autoIt, but that will just get you a different error message - a NoMethodError. You can define the Autoit class like this: require 'win32ole' class AutoIt < WIN32OLE def initialize super("AutoItX3.Control") end end $autoit = AutoIt.new But I would just do: require 'win32ole' $autoit = WIN32OLE.new("AutoItX3.Control") And with either, you should be able to use the methods and properties as you expect from the doco: $autoit.mouseclick "left" # or MouseClick or mOuSeClIcK... Another way is a little more complicated: require 'win32ole' module AutoIt class << self def instance unless @instance @instance = WIN32OLE.new("AutoItX3.Control") end @instance end def method_missing(*args, &block) instance.send(*args, &block) end end end This will automatically create the AutoIt control when it's needed. You don't need to explicitly create it -- use it like this: AutoIt.mouseclick "left" Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to open right-click context menu?
Mike wrote: Alas, it won't fix my current problem. I can already view source for this particular window, but it's showing me source for just one of the frames, and not the one I care about. Even clicking on the frame I want and then looking at view source doesn't change anything. This page was written by extremely sharp individuals who I believe were intentionally trying to obfuscate. The page has an unnamed frame, which I could only get a handle on by doing this: $main_frame = $ie.frame("") Within this frame are other frames. If you can think of other ways to get at the source of specific frames, please let me know. I'll also try AutoIt as a previous poster recommended. You can try pulling it out of the cache (C:\Documents and Settings\username\Local Settings\Temporary Internet Files). Or AutoIt can probably do it; I imagine that could potentially be harder than looking for a matching filename in the cache. P.S. Do you have a good reference for that kind of window scripting, especially IE scripting? Is there a way to banish those annoying splash screens that s-l-o-w Java applications keep putting up in front of my work? AutoIt3 does all that really well, although Bret seems to have demonstrated you can use the Windows COM API quite powerfully, too. You can check the MSDN library for info on Shell and other automation objects, including the IE object which is very handy for Watir stuff. InternetExplorer object (Watier::IE.new.ie or WIN32OLE.new("InternetExplorer.Application") doco is here: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/objects/internetexplorer.asp Remember, too, all WIN32OLE objects have the ole_methods method which exposes all the properties and methods of the object. The AutoIt docs are here: http://www.autoitscript.com/autoit3/docs/ And in particular its API is here: http://www.autoitscript.com/autoit3/docs/functions.htm Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to detect the number of certain word in a page
jim che asked: I want to detect the number of certain word in a page .For example in a page there contains 20 'Hello' and I want to get the number of 'Hello' How can I detect it which apis can be used? Watir::IE#text returns the text in the page (excluding titles, tags, etc) as a String. String#scan(regexp) returns an array of the bits of the string that match the regexp. Array#size returns the number of elements in the array. require 'watir' ie = Watir::IE.new ie.goto("http://hello.com";) p ie.text.scan(/hello/i).size Cheers Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] new installers
Bret Pettichord wrote: I'm thinking about using rake for the cli installer (rake install, with other targets for lib-install, etc). But that would mean that the users of the installer would need to have rake installed, which isn't part of the ruby distro. (although you can do a gem install rake.) Thoughts? "gem install watir" is ideal. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Re: Javascript dialogs - reading and closing
Joe Yakich wrote: Thanks so much for posting this code, it looks like it will be exactly what we need to start handling our Javascript dialogs. You're welcome. I hope it works as well for you as it does for me. Did I mention it requires AutoIt? I have a question (and it's probably an obvious one that I should know, so please excuse my ignorance). Does one actually modify Test::Unit::Assertions (Ruby\lib\ruby\1.8 \test\unit\assertions.rb in my case) and add the assert_js_dialog method, or is there some preferred way to extend it? (Are there other setup/installation steps or gotchas that I should know about?) If you follow my instructions blindly, and just put all my code in one file then require it, it will work. Ruby is an open language. That means js_dialog.rb is allowed to open up Test::Unit::Assertions and add a method to it, which will be included anywhere that module is included (e.g. in any Test::Unit::TestCase). This is the same way that you can add a method that is available everywhere. If you use "def" to write a method "at the top level" of a script, it's added to Object, and so you can use it anywhere. I'd recommend books, but I won't right now; I'll instead just plug learning Ruby itself. It's good. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Unicode and Watir
Jeff Wood suggested: http://www.dave.burt.id.au/ruby/iconv.zip Hope that helps. I haven't played with it yet, but I thought I'd pass the info along. It works for me. Documentation for iconv is available with the doco for the rest of the Ruby standard library, at http://www.ruby-doc.org/ In particular: http://www.ruby-doc.org/stdlib/libdoc/iconv/rdoc/index.html Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Javascript dialogs - reading and closing
Hi List, I've been using the following script to read and close javascript alert() and confirm() dialogs in Watir. It could fairly easily be extended to deal with file choosers, as I saw someone asking for earlier. To be clear, it will wait a dialog to be shown and close it using the given button, and it can test for certain text in the dialog itself. It lets you do this: require 'js_dialog' assert_js_dialog do @ie.button(:value, "Alert test").click end assert_js_dialog /sample dialog text/, "Cancel" do @ie.button(:value, "Confirm test").click end Code below. Cheers, Dave - js_dialog.rb - require 'win32ole' # # Use AutoIt to read and close Javascript dialog windows # module JavascriptDialog # # Target javascript dialogs with this window title # WINDOW_TITLE = "Microsoft Internet Explorer" class << self # # Return the text contained in a javascript dialog (e.g. an "alert()") # if such a dialog is present or appears within +wait_seconds+. # def text(wait_seconds = 1) # sleep 0.3 autoit.WinWait(WINDOW_TITLE, nil, wait_seconds) if wait_seconds s = autoit.WinGetText(WINDOW_TITLE) s unless s == "1" end # # Close any active javascript dialog # def close autoit.WinClose WINDOW_TITLE end # # Press the "OK" button on a javascript dialog # def ok autoit.ControlClick(WINDOW_TITLE, "", "OK") end # # Press the "Cancel" button on a javascript dialog # def cancel autoit.ControlClick(WINDOW_TITLE, "", "Cancel") end # # Press the "Yes" button on a javascript dialog # def yes autoit.ControlClick(WINDOW_TITLE, "", "Yes") end # # Press the "No" button on a javascript dialog # def no autoit.ControlClick(WINDOW_TITLE, "", "No") end private # # Return an AutoIt COM object, creating it if it doesn't already # exist # def autoit unless defined? @@autoit @@autoit = WIN32OLE.new("AutoItX3.Control") end @@autoit end end end module Test::Unit::Assertions # # Passes if a Javascript dialog appears within +wait_seconds+ and its # text matches the given (optional) pattern. # # Use like this: # assert_js_dialog do #watir_command_to_make_dialog_appear # end # Or like this: # assert_js_dialog /Text to find in the dialog/, "Cancel" do #watir_command_to_make_dialog_appear # end # def assert_js_dialog(pattern = //, action = "close", message = nil) _wrap_assertion do begin pipe = IO.popen("ruby js_dialog.rb #{action}") yield window_text = pipe.read rescue "" pipe.close unless window_text.empty? assert_block(build_message(message, " not found in JavaScript dialog.", pattern)) do window_text.match(pattern) end else raise Test::Unit::AssertionFailedError.new( build_message(message, "No JavaScript window found.")) end ensure pipe.close if pipe && !pipe.closed? end end end end # test - will close and print the text of an opened javascript dialog if # run as "ruby js_dialog.rb" if $0 == __FILE__ action = ARGV.shift || "close" print JavascriptDialog.text || "" JavascriptDialog.send action end ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Is Watir suitable for Web app (.Net Framework)?
Hue Mach Dieu wrote: Dear All, I just finished the web automation test use Watir. Now I have new web project (base on .Net framework) may be use C# or ASP.net. I would like to know is Watir suitable for it. Watir drives IE. It's suitable for testing any application that uses IE as a client. It will only test that level - as if a user is accessing the app with IE. You probably want unit tests in .NET as well, to test lower level stuff, functions, classes, etc. Use NUnit for that. Cheers, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general