Re: [Wtr-general] How can I open and attach file using file_field method?
I encountered this problem yesterday, and unlike the mail archives, I have an answer. I was getting exactly the behavior described below: 1) I would run a script using file_field.set 2) The script would get to the set method 3a) the choose file window would be invoked 3b) the file setFileDialog.rb would be opened in my ruby editor 3c) the script would sit there waiting for me to take manual action. 4) As soon as I take manual action to close the window, the script would resume Messing around with autoit, and the other suggestions didn't help at all. The problem seems to be caused by associating *.rb files with an IDE. When the set method attempts to start the thread that manipulates the Choose File window, the operating system directs the script to the IDE rather than to Ruby. As soon as I changed the association to the Ruby executable, the file_field set method worked happily. (Well, not quite happily... The method still doesn't like spaces in the path name, but that's an easy problem to solve.) I assume that Watir launching a new thread and telling the thread to execute setFileDialog.rb, while what it needs to do is tell the thread to execute setFileDialog.rb *with Ruby*. Either that or people getting this bug need to change the file associations. Michael Ruschena Cain, Mark Thu, 12 Jan 2006 07:32:28 -0800 What behavior do you see? When my script runs I see a Dos window open with focus (just like WinClicker), then the file chooser window open under the Dos window. The Dos window scrolls through all the objects open and finally gets to the File Chooser window, the document name (from $path) appears in the file name field, the open button is clicked and that information is transferred to the file_field text boxes. Finally the submit button is clicked and the file is attached. --Mark From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of chaya shetty Sent: Wednesday, January 11, 2006 10:11 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How can I open and attach fileusingfile_fieldmethod? Hi, I tried as said...Even then I am facing the same problem. Code Used: $path = C:/Watir/file.txt $ie.file_field(:name,srcfile).set($path) $autoit = WIN32OLE.new(AutoItX3.Control) $autoit.WinWait(Choose file, Do you want to open or save this file?, 3) $autoit.WinActivate(Choose file) $autoit.WinWait(Choose file, Look in, 3) $autoit.ControlSetText(Choose file, , Edit1, #{$path}) $autoit.ControlClick(Choose file, Look in, Open) $ie.button(:name, Open).click The file field highlights(yellow)and opens choose file dialog along with another ruby file with contents: # # setFileDialog.rb # # # This file contains the file dialog when it runs as a separate process $LOAD_PATH ! lt; File.expand_path(File.join(File.dirname(__FILE__), '..')) puts $LOAD_PATH require 'watir/winClicker' filepath = invalid path passed to setFileDialog.rb filepath = ARGV[0] unless ARGV[0] == nil clicker= WinClicker.new clicker.setFileRequesterFileName(filepath) clicker = nil Then it waits for me to manually select the file and attach. I have ensured that the path is correct and there is a text file viz. file in the Watir folder. Thanks, Chaya Cain, Mark [EMAIL PROTECTED] wrote: Replace all your $autoit lines with this: $autoit = WIN32OLE.new(AutoItX3.Control) $autoit.WinWait(Choose file, Do you want to open or save this file?, 3) $autoit.WinActivate(Choose file) $autoit.WinWait(Choose file, Look in, 3) $autoit.ControlSetText(Choose file, , Edit1, #{$path}) $autoit.ControlClick(Choose file, Look in, Open) I don't know if it will make a difference but my script needed the WinWait's left in to work right. Also, it took a little time for autoit to find the window so don't get impatient. Hope this helps, --Mark From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of chaya shetty Sent: Thursday, January 05, 2006 9:27 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How can I open and attach file usingfile_fieldmethod? Hi, There is only one file field in the page and hence I tried with path = C\:Watir\Text.doc ie.file_field(:index,1).set(#{path}) $autoit = WIN32OLE.new(AutoItX3.Control) $autoit.WinActivate(Choose file) $autoit.ControlSetText(Choose file, , Edit1, #{path}) $autoit.ControlClick(Choose file, Look in, Open) $ie.button(:name, Submit).click B! ut still the same behaviour was seen. The file field was accessed and the Choose
Re: [Wtr-general] How can I open and attach file using file_field method?
If you want it fixed, enter a new case at Jira (http://jira.openqa.org/browse/WTR), so it would not be forgotten. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Determine HTML property
Hi, I have an HTML field that once saved becomes read-only [readonly=true]. Apart from doing a regex on the source how can I determine this property? Cheers Aidy --- This message and any attachment are confidential and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person. --- ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Determine HTML property
ie.radio(:id, id).readonly?On 6/1/06, Adrian Rutter [EMAIL PROTECTED] wrote: Hi,I have an HTML field that once saved becomes read-only [readonly=true].Apart from doing a regex on the source how can I determine this property?CheersAidy--- This message and any attachment are confidential and may be privileged or otherwise protected from disclosure.If you are not the intended recipient, please telephone or email the sender and delete this message and any attachment from your system. If you are not the intended recipient you must not copy this message or attachment or disclose the contents to any other person.--- ___Wtr-general mailing listWtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general -- http://www.testingreflections.com/blog/3071 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How can I open and attach file using file_field method?
Thanks for solving this problem.Now that we have a click_no_wait method, we shouldn't have to resort to external *.rb files in the first place.BretOn 6/1/06, Michael Ruschena [EMAIL PROTECTED] wrote: I encountered this problem yesterday, and unlike the mail archives, I havean answer. I was getting exactly the behavior described below:1) I would run a script using file_field.set2) The script would get to the set method 3a) the choose file window would be invoked3b) the file setFileDialog.rb would be opened in my ruby editor3c) the script would sit there waiting for me to take manual action.4) As soon as I take manual action to close the window, the script would resumeMessing around with autoit, and the other suggestions didn't help at all.The problem seems to be caused by associating *.rb files with an IDE. Whenthe set method attempts to start the thread that manipulates the Choose File window, the operating system directs the script to the IDE rather than toRuby. As soon as I changed the association to the Ruby executable, thefile_field set method worked happily. (Well, not quite happily... The method still doesn't like spaces in the path name, but that's an easy problem tosolve.)I assume that Watir launching a new thread and telling the thread to executesetFileDialog.rb, while what it needs to do is tell the thread to execute setFileDialog.rb *with Ruby*. Either that or people getting this bug need tochange the file associations.Michael RuschenaCain, MarkThu, 12 Jan 2006 07:32:28 -0800 What behavior do you see?When my script runs I see a Dos window open withfocus (just like WinClicker), then the file chooser window open under theDos window.The Dos window scrolls through all the objects open and finally gets to the File Chooser window, the document name (from $path) appears inthe file name field, the open button is clicked and that information istransferred to the file_field text boxes.Finally the submit button is clicked and the file is attached.--MarkFrom: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of chaya shettySent: Wednesday, January 11, 2006 10:11 PM To: wtr-general@rubyforge.orgSubject: Re: [Wtr-general] How can I open and attachfileusingfile_fieldmethod?Hi, I tried as said...Even then I am facing the same problem. Code Used:$path = C:/Watir/file.txt $ie.file_field(:name,srcfile).set($path) $autoit = WIN32OLE.new(AutoItX3.Control) $autoit.WinWait(Choose file, Do you want to open or save this file?, 3) $autoit.WinActivate(Choose file) $autoit.WinWait(Choose file, Look in, 3) $autoit.ControlSetText(Choose file, , Edit1, #{$path}) $autoit.ControlClick(Choose file, Look in, Open) $ie.button(:name, Open).clickThe file field highlights(yellow)and opens choose file dialog along with another ruby file with contents:##setFileDialog.rb### This file contains the file dialog when it runs as a separate process$LOAD_PATH ! lt; File.expand_path(File.join(File.dirname (__FILE__), '..'))puts $LOAD_PATHrequire 'watir/winClicker'filepath = invalid path passed to setFileDialog.rbfilepath = ARGV[0] unless ARGV[0] == nilclicker= WinClicker.newclicker.setFileRequesterFileName (filepath)clicker = nil Then it waits for me to manually select the file and attach.I have ensured that the path is correct and there is a text file viz. filein the Watir folder. Thanks,ChayaCain, Mark [EMAIL PROTECTED] wrote:Replace all your $autoit lines with this:$autoit = WIN32OLE.new(AutoItX3.Control )$autoit.WinWait(Choose file, Do you want to open or save thisfile?, 3)$autoit.WinActivate(Choose file)$autoit.WinWait(Choose file, Look in, 3) $autoit.ControlSetText(Choose file, , Edit1, #{$path})$autoit.ControlClick(Choose file, Look in, Open) I don't know if it will make a difference but my script needed theWinWait's left in to work right.Also, it took a little time for autoit tofind the window so don't get impatient. Hope this helps,--MarkFrom: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On BehalfOf chaya shettySent: Thursday, January 05, 2006 9:27 PM To: wtr-general@rubyforge.orgSubject: Re: [Wtr-general] How can I open and attach fileusingfile_fieldmethod?Hi,There is only one file field in the page and hence I tried with path = C\:Watir\Text.docie.file_field(:index,1).set(#{path})$autoit = WIN32OLE.new(AutoItX3.Control) $autoit.WinActivate(Choose file) $autoit.ControlSetText(Choose file, , Edit1, #{path}) $autoit.ControlClick(Choose file, Look in, Open) $ie.button(:name, Submit).clickB! ut still the same behaviour was seen.The file field was accessed and the Choose File window opened and waited till I manually selected the file.ThanksChayaCain, Mark [EMAIL PROTECTED] wrote:Yes, the problem is (:value, 'Value') in this line: ie.file_field(:value,'Value').set(#{path})! The file_field supports these attributes::id, :name,:index.Do a view source and find out what the attribute values for your input type = file tag.If for some reason
Re: [Wtr-general] Methods that can be used within a frame?
Well I may not even have to deal with it anymore, but how would I change this manually? I do not have control over the HTML in the page, I am only interacting with it via Watir.On 5/31/06, Bret Pettichord [EMAIL PROTECTED] wrote: On 5/31/06, Tyler Prete [EMAIL PROTECTED] wrote: Thank you for the help David. It looks like for now I will just have to try and work-around the frame issue... probably won't be too bad. I would post some actual code but I am writing this for use with a company intranet, so it wouldn't do much good anyway. What frame issue? If you want to change the page frames that a main page loads, the way to do that is to change the main page itself. You do all of this in HTML. I'm not sure i understand what you are trying to do. Are you trying to do something that you can do manually? Bret ___Wtr-general mailing listWtr-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] RPC Server unavailable
Title: RPC Server unavailable Yesterday I spent a bunch of time getting my watir and ruby versions synchronized on the various machines I use for developing and running tests. I am now using: Ruby 1.8.2-15 Stable Release watir-1.5.1.1017 Is this the right (or at least a good) Ruby version to use with the latest Watir? I scoured watir.com and the wiki for recommendations on this but couldn't find any. Anway, I am now receiving the RPC Server unavailable message intermittently when running tests. I found an old discussion on this (http://rubyforge.org/pipermail/wtr-general/2006-January/004634.html) where Bret recommends: 1. Add time delays between the ie.close and ie.new or ie.start. This will give a chance for the ie.close to really close. 2. Don't close IE -- just reuse the existing client between tests. 3. Create an additional IE. As long as this lives, the IE server will continue to live and you can close and create IE windows without worry. I presume you are using Watir 1.4. The watir library in HEAD uses option 3 to avoid this problem. Am I seeing a different problem since I'm using watir-1.5? Or is it the same thing? If it is the same thing, how do I do #3? Dara Lillis Software Testing SunGard Kiodex 628 Broadway, Suite 501, New York, NY 10012 Tel 646-437-2627 Fax 646-437-3910 http://www.sungard.com/Kiodex CONFIDENTIALITY: This email (including any attachments) may contain confidential, proprietary and privileged information, and unauthorized disclosure or use is prohibited. If you received this email in error, please notify the sender and delete this email from your system. Thank you. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] RPC Server unavailable
On 6/1/06, Lillis, Dara [EMAIL PROTECTED] wrote: Yesterday I spent a bunch of time getting my watir and ruby versions synchronized on the various machines I use for developing and running tests. I am now using: Ruby 1.8.2-15 Stable Release watir-1.5.1.1017 Is this the right (or at least a good) Ruby version to use with the latest Watir? I scoured watir.com and the wiki for recommendations on this but couldn't find any.That should be fine. Anway, I am now receiving the RPC Server unavailable message intermittently when running tests. I found an old discussion on this ( http://rubyforge.org/pipermail/wtr-general/2006-January/004634.html ) where Bret recommends: 1. Add time delays between the ie.close and ie.new or ie.start. This will give a chance for the ie.close to really close. 2. Don't close IE -- just reuse the existing client between tests. 3. Create an additional IE. As long as this lives, the IE server will continue to live and you can close and create IE windows without worry. I presume you are using Watir 1.4. The watir library in HEAD uses option 3 to avoid this problem. Am I seeing a different problem since I'm using watir-1.5? Or is it the same thing? If it is the same thing, how do I do #3?Good question.Option 3 was causing problems when it was enabled by default, so i turned it off. You can turn it back on with Watir::IE.persist_ole_connection = trueThis is an as yet undocumented feature.Please let us know whether this helps. Or whether it creates other problems. I wish i remember the exact problems that lead me to turn it off. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Methods that can be used within a frame?
On 6/1/06, Tyler Prete [EMAIL PROTECTED] wrote: Well I may not even have to deal with it anymore, but how would I change this manually? I do not have control over the HTML in the page, I am only interacting with it via Watir.By design, Watir is a tool for automating things that you can do manually. If you don't know how to do it manually, then Watir is probably the wrong tool for you. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] `method_missing': document (WIN32OLERuntimeError)
Please send HTML page and code.On 5/24/06, Manish Sapariya [EMAIL PROTECTED] wrote: Is this one known?I searched through the archive and could not find anything similar to this.I saw this only first time, and I am not sure whether I will see thisagain with the same script.Please let me know if HTML page or code will help isolate this problem. Thanks and Regards,Manishc:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:2447:in`method_missing': document(WIN32OLERuntimeError)OLE error code:80070005 in Unknown Access is denied.HRESULT error code:0x80020009Exception occurred.from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:2447:in`document'from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:1059:in`check_for_http_error'from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:205from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir- 1.5.0.1005/./watir.rb:203:in `upto'from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:203from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:201:in `call' from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:1558:in`run_error_checks'from c:/programfiles/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:1557:in `each' ... 6 levels...from riGuardSelfTest_2_2_1.rb:374:in `CreateAndScheduleFTPSearch'from riGuardSelfTest_2_2_1.rb:371:in `each'from riGuardSelfTest_2_2_1.rb:371:in `CreateAndScheduleFTPSearch' from riGuardSelfTest_2_2_1.rb:759___Wtr-general mailing listWtr-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] [question] Setting timeout for a ie.wait method?
I'm doing this because I need to test if a page has been loaded correctly after clicking a link, maybe there's a easier form of checking this.. def wait_for_page(seconds) begin @ie.link(:text,My Incredibly Important Link).click do_the_next_thing_method rescue sleep 1 seconds = seconds + 1 if seconds == 10 puts waited over 10 seconds for Incredibly Important Link, tried 10 times, exiting exit end wait_for_page(seconds) #CALL THE SAME METHOD AGAIN end I haven't tested it but it should be OK. -Chris ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
On 6/1/06, Rodrigo Julian Martin [EMAIL PROTECTED] wrote: I was wondering if there's a way of setting the timeout parameter for the .wait method… I mean, let's say that a page doesn't load in 10 seconds. Could I trap that the .wait method failed after 10 seconds in order to log that? I'm doing this because I need to test if a page has been loaded correctly after clicking a link, maybe there's a easier form of checking this..If all you want to do is verify how long it took to load a page, you can do this: ie.link(:name, foo).click assert( ie.down_load_time 10)I have actually been thinking of adding a timeout to the wait method, but i'm not sure your situation really needs it. BretP.S. I have my doubts about McMahon's suggestion. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
P.S. I have my doubts about McMahon's suggestion. :) I'm doing something very similar to this in my current Watir scripts right now, except I haven't put in the max-retries logic yet. -Chris ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
The problem is that link().click won't return until the page is loaded. Maybe you meant to use link().ole_object.click instead?BretOn 6/1/06, Chris McMahon [EMAIL PROTECTED] wrote: P.S. I have my doubts about McMahon's suggestion.:)I'm doing something very similar to this in my current Watir scriptsright now, except I haven't put in the max-retries logic yet.-Chris___ Wtr-general mailing listWtr-general@rubyforge.orghttp://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
On 6/1/06, Bret Pettichord [EMAIL PROTECTED] wrote: The problem is that link().click won't return until the page is loaded. Maybe you meant to use link().ole_object.click instead? Ah, you're right, I misunderstood the original question. Rodrigo, in my case, I have interim pages that show messages to the user before the page I need to manipulate arrives. Also, I have pages that have frames, and the frames take longer to load than the outer page does. So I've written these little looping checkers that don't do the next action until the right part of the page is in place. If that's your issue, then my code will work well for you. If you have simple pages that just don't load, then another approach is in order. -Chris ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
I had a similar requirement and addressed it by adding my methods to the Element class. This may not be the best solution, but it worked for me. module Watir class Element def click_wait(how_long = 30) wait_for(how_long) click end def wait_for(how_long=30) 0.upto(how_long-1) do |n| if exists? if enabled? puts Waited #{n} sec for #{self.class}(:[EMAIL PROTECTED], [EMAIL PROTECTED]) if n 0 return end end sleep 1 end raise (#{self.class}(:[EMAIL PROTECTED], [EMAIL PROTECTED]) not found after #{how_long} sec) if ! exists? raise (#{self.class}(:[EMAIL PROTECTED], [EMAIL PROTECTED]) not enabled after #{how_long} sec) end end end ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Setting timeout for a ie.wait method?
Thanks for all your replies The Chris McMahon answer doesnt fit exactly with what Im trying to do, but maybe is a good approach Bret, with the assert sentence, can I say something like If assert fails, do some code? John, I cant understand your code, I guess Im too newbie to OO programmingAre you waiting always for 30 seconds? Could this be parametrized too? Thanks again to all of you! From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bret Pettichord Sent: Jueves, 01 de Junio de 2006 03:50 p.m. To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] [question] Setting timeout for a ie.wait method? The problem is that link().click won't return until the page is loaded. Maybe you meant to use link().ole_object.click instead? Bret On 6/1/06, Chris McMahon [EMAIL PROTECTED] wrote: P.S. I have my doubts about McMahon's suggestion. :) I'm doing something very similar to this in my current Watir scripts right now, except I haven't put in the max-retries logic yet. -Chris ___ 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] Methods that can be used within a frame?
Tyler, What I've done in the past is to create a new method, Element#html= which allows you to replace the outerHTML for any element: class Watir::Element def html=(new_html) assert_exists @o.outerHTML = new_html end end Unfortunately, when playing with your top level document that contains the frameset there wasn't any Watir::Element I could grab. I tried doing it manually by taking different document elements on that top page and trying to do the change like: ie.document.body.outerhtml = BODYtest/BODY Even though e.document.body.ole_put_methods shows that we should be able to do this (an outerHTML put call exists) when tried I got the following error: irb(main):029:0 ie.document.body.outerhtml = BODYtest/BODY WIN32OLERuntimeError: OLE error code:800A0258 in htmlfile No Description HRESULT error code:0x80020009 Exception occurred. from (irb):29:in `method_missing' from (irb):29 So in Tyler's case, I was unable to find a way to change the frame element in his top HTML. However, I often use this replacement technique to prevent popups by changing the HTML attributes like this: ie.text_field(:id, 'xxx').html = ie.text_field(:id, 'xxx').html.sub(/ onclick=\S+/, '') which clears out the onclick=... from the element. David Bret Pettichord wrote: On 6/1/06, *Tyler Prete* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Well I may not even have to deal with it anymore, but how would I change this manually? I do not have control over the HTML in the page, I am only interacting with it via Watir. By design, Watir is a tool for automating things that you can do manually. If you don't know how to do it manually, then Watir is probably the wrong tool for you. 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] Determine HTML property
Zeljko Filipin wrote: ie.radio(:id, id).readonly? On 6/1/06, *Adrian Rutter* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi, I have an HTML field that once saved becomes read-only [readonly=true]. Apart from doing a regex on the source how can I determine this property? Cheers Aidy I've just encountered a situation where this doesn't work, and written a fix for it, though I'm not sure where this fix would best be integrated. The problem is that while an input element may NOT be read only, a containing element like a table cell, table row or div may have their visibility turned off, which prevents Watir from setting the focus on the input element and effectively makes the input element read only even though the readonly attribute is false: irb(main):014:0 ie.text_field(:id, 'Detail_Date').readonly? = false irb(main):015:0 ie.text_field(:id, 'Detail_Date').set('01/01/2000') WIN32OLERuntimeError: focus OLE error code:800A083E in htmlfile Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus. HRESULT error code:0x80020009 Exception occurred. from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1010/./watir.rb:3871:in `method_missing' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1010/./watir.rb:3871:in `set' from (irb):15 In this case, a TR element a few levels higher has a style of visibility: hidden; display: none so the control is invisible and thus read only. I see a few solutions. The first would be to try to update the input element and then rescue the WIN32OLERuntimeError exception. I'm not particularly fond of this, especially since the exception isn't an exception specific to this problem. Another option is to iterate up the DOM elements checking every element to make sure that is is visible. This could be done in Element#readonly?, but then we wouldn't be able to see the value of the actual readonly attribute. I chose to implement another method which I called writable? which first checks that the element exists, is enabled and not readonly and then moves up the DOM tree and reports false if any element is not visible (visibility != 'hidden' and display != 'none'). I've tested this and while it can be slow if the input element is deeply embedded it *does* seem to be accurate: irb(main):016:0 ie.text_field(:id, 'Detail_Date').writable? = false irb(main):017:0 ie.text_field(:id, 'Detail_DOB').writable? = true You can try this by adding the following method in your Watir script or by adding just the writable? definition inside class Element in Watir.rb. I can add this to trunk once I get some tests written to test it if we decide this is the way to go. Does anyone have a cleaner or faster way to do this? module Watir class Element # Determine if we can write to a DOM element. # If any parent element isn't visible then we cannot write to the # element. The only realiable way to determine this is to iterate # up the DOM elemint tree checking every element to make sure it's # visible. def writable? assert_exists # First make sure the element itself is writable begin assert_enabled assert_not_readonly rescue Watir::Exception::ObjectDisabledException, Watir::Exception::ObjectReadOnlyException return false end return false if ! document.iscontentEditable # Now iterate up the DOM element tree and return false if any # parent element isn't visible or is disabled. object = document while object begin if object.style.invoke('visibility') =~ /^hidden$/i return false end if object.style.invoke('display') =~ /^none$/i return false end if object.invoke('isDisabled') return false end rescue WIN32OLERuntimeError end object += '.parentElement' end true end end end ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Methods that can be used within a frame?
Bret, I think we are having some syntactic problems. I CAN do it manually, by interacting with the page myself. I'll try and explain the situation since I can't actually give an example. I am working with a customer service app that has multiple frames, a search bar on the left, a customer frame in the top right, and an invoice frame in the top left. When a search is issued that can result in multiple people, a popup window is opened containing all the names of possible customers. When a name is selected, the customer frame is supposed to change to show that specific customer. When I go through the process myself, it works. However, when using watir, I can click on the link, but it does not load the customer info in the customer frame. I could not get it to work directly, so my idea was to take the link URL and load it manually in the frame, but apparently this is not possible, at least not at this time. Hopefully that helps clear things up.--TylerOn 6/1/06, Bret Pettichord [EMAIL PROTECTED] wrote: On 6/1/06, Tyler Prete [EMAIL PROTECTED] wrote: Well I may not even have to deal with it anymore, but how would I change this manually? I do not have control over the HTML in the page, I am only interacting with it via Watir. By design, Watir is a tool for automating things that you can do manually. If you don't know how to do it manually, then Watir is probably the wrong tool for you. Bret ___Wtr-general mailing listWtr-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 create a script for calendar function?
Try ie2.show_links to see all the links in the page and ie2.show_tables to see all the tables in the page Looking at the code snippet -- ie2.link(:text, '2').click should set the date to '2006-06-02' ie2.link(:id, ).click should set the date to '2006-06-02' Ie2.table(:index, 2)[2][6].click should set the date to '2006-06-02' ie2.table(:index, )[2][6].fireEvent('onclick') should also set the date to '2006-06-02' Also ie2.link(:text, '').click should move the year back ie2.link(:text, '').click should move the year forward ie2.link(:text, '').click should move the month forward ie2.link(:text, 'Print').click should print (I assume) etc. Likewise ie2.table(:index, 1)[1][1].click will move the year back ie2.table(:index, 1)[1][1].fireEvent will move the year back etc. I recommend identifying the links by :text (simple to code and read) -- but there are many other ways to do the same thing. Hope this helps. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danilova, Elza Sent: Thursday, June 01, 2006 10:34 AM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Hi, Using the following: ie.link(:url,javascript:show_calendar'resultsearch.gDate')).click ie2=Watir::IE.attach(:title, Calendar) we were able to open the calendar icon, but could not go any further, because there is no object name on the calendar.html page: ---Objects in page - name= id= name= id= name= id= name= id= name= id= Calendar html: html headtitleCalendar/title /head body link=black vlink=black alink=black text=black FONT FACE='Verdana' SIZE=2BJune 2006/BBRTABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'TRTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2005', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '4', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.print();Print/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '6', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2007', 'MONTH DD, ');/A]/TD/TR/TABLEBR TABLE BORDER=1 BGCOLOR=whiteTRTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSun/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BMon/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BTue/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BWed/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BThu/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BFri/B/FONT/TDTD WIDTH='16%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSat/B/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-01';wind ow.close();FONT COLOR=REDB1/B/FONT/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-02';wind ow.close();2/A/FONT/TDTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.graDate.value='2006-06-03';wi ndow.close();3/A/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-04';wind ow.close();4/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-05';wind ow.close();5/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-06';wind ow.close();6/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-07';wind ow.close();7/A/FONT/TD/TABLE /BODY /HTML -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Attebery, Bill Sent: Wednesday, May 31, 2006 6:10 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Not sure if all calendar functions are created equal -- the one used at my site pops up another IE window -- I can attach to it and then drive it like always. ie.image(:id, 'my_calendar_icon').click @ie2=IE.attach(:title, /Select Date/) Now @ie2 is another browser instance with select_lists, links, buttons, etc. available to control through regular watir statements.
Re: [Wtr-general] How to create a script for calendar function?
Oops -- typo 2nd example should be ie2.link(:index, 7).click should set the date to '2006-06-02' -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Attebery, Bill Sent: Thursday, June 01, 2006 4:06 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Try ie2.show_links to see all the links in the page and ie2.show_tables to see all the tables in the page Looking at the code snippet -- ie2.link(:text, '2').click should set the date to '2006-06-02' ie2.link(:id, ).click should set the date to '2006-06-02' Ie2.table(:index, 2)[2][6].click should set the date to '2006-06-02' ie2.table(:index, )[2][6].fireEvent('onclick') should also set the date to '2006-06-02' Also ie2.link(:text, '').click should move the year back ie2.link(:text, '').click should move the year forward ie2.link(:text, '').click should move the month forward ie2.link(:text, 'Print').click should print (I assume) etc. Likewise ie2.table(:index, 1)[1][1].click will move the year back ie2.table(:index, 1)[1][1].fireEvent will move the year back etc. I recommend identifying the links by :text (simple to code and read) -- but there are many other ways to do the same thing. Hope this helps. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danilova, Elza Sent: Thursday, June 01, 2006 10:34 AM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Hi, Using the following: ie.link(:url,javascript:show_calendar'resultsearch.gDate')).click ie2=Watir::IE.attach(:title, Calendar) we were able to open the calendar icon, but could not go any further, because there is no object name on the calendar.html page: ---Objects in page - name= id= name= id= name= id= name= id= name= id= Calendar html: html headtitleCalendar/title /head body link=black vlink=black alink=black text=black FONT FACE='Verdana' SIZE=2BJune 2006/BBRTABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'TRTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2005', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '4', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.print();Print/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '6', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2007', 'MONTH DD, ');/A]/TD/TR/TABLEBR TABLE BORDER=1 BGCOLOR=whiteTRTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSun/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BMon/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BTue/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BWed/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BThu/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BFri/B/FONT/TDTD WIDTH='16%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSat/B/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-01';wind ow.close();FONT COLOR=REDB1/B/FONT/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-02';wind ow.close();2/A/FONT/TDTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.graDate.value='2006-06-03';wi ndow.close();3/A/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-04';wind ow.close();4/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-05';wind ow.close();5/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-06';wind ow.close();6/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-07';wind ow.close();7/A/FONT/TD/TABLE /BODY /HTML -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Attebery, Bill Sent: Wednesday, May 31, 2006 6:10 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Not sure if all calendar
Re: [Wtr-general] Methods that can be used within a frame?
I can't provide the full html because I don't have access to it, but here is the link I am trying to click from the popup:a href='' target='cust' 8560113/aI imagine part of the problem is related to the onclick _javascript_ event, however I did try calling it seperately with no success. On 6/1/06, Bret Pettichord [EMAIL PROTECTED] wrote: On 6/1/06, Tyler Prete [EMAIL PROTECTED] wrote: When I go through the process myself, it works. However, when using watir, I can click on the link, but it does not load the customer info in the customer frame.This is the problem we should focus on. Can you provide more information? Are you getting an error message? Can you show us any code or html? -- feel free to sanitize. ___Wtr-general mailing listWtr-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 create a script for calendar function?
*IF* (this is a big if, because I am not familiar with the calendar thing) the elements are in a predicable pattern on the page, then here is a possible avenue of approach: You could access the elements by index, and use the html= method of David's to give them names or IDs. Then access as usual . . . Lonny Eachus = -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Danilova, Elza Sent: Thursday, June 01, 2006 10:34 AM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] How to create a script for calendar function? Hi, Using the following: ie.link(:url,javascript:show_calendar'resultsearch.gDate')).click ie2=Watir::IE.attach(:title, Calendar) we were able to open the calendar icon, but could not go any further, because there is no object name on the calendar.html page: ---Objects in page - name= id= name= id= name= id= name= id= name= id= Calendar html: html headtitleCalendar/title /head body link=black vlink=black alink=black text=black FONT FACE='Verdana' SIZE=2BJune 2006/BBRTABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'TRTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2005', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '4', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.print();Print/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '6', '2006', 'MONTH DD, ');/A]/TDTD ALIGN=center [A HREF=javascript:window.opener.Build('resultsearch.gDate', '5', '2007', 'MONTH DD, ');/A]/TD/TR/TABLEBR TABLE BORDER=1 BGCOLOR=whiteTRTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSun/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BMon/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BTue/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BWed/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BThu/B/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BFri/B/FONT/TDTD WIDTH='16%'FONT SIZE='2' FACE='Verdana' COLOR='darkgreen'BSat/B/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana' /FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-01';wind ow.close();FONT COLOR=REDB1/B/FONT/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-02';wind ow.close();2/A/FONT/TDTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.graDate.value='2006-06-03';wi ndow.close();3/A/FONT/TD/TRTRTD WIDTH='14%' BGCOLOR=#e0e0e0FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-04';wind ow.close();4/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-05';wind ow.close();5/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-06';wind ow.close();6/A/FONT/TDTD WIDTH='14%'FONT SIZE='2' FACE='Verdana'A HREF='#' onClick=self.opener.document.resultsearch.gDate.value='2006-06-07';wind ow.close();7/A/FONT/TD/TABLE /BODY /HTML ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general