Re: [Wtr-general] Using Excel
Tiffany, I've generated r-doc documentation for the XLS class and uploaded it to the watir site (http://wiki.openqa.org/display/WTR/Excel+interface+class). It includes some short comments on the methods used to write to excel (also listed below). There should be examples of using each of the methods in the associated unit tests. Here are the methods for writing to excel: def write2DArray(data, myRange,sheet = nil) #writes out the 2D Array *data* starting at the specified range *myRange* on the specified sheet def writeArrayHash(data, myRange,sheet = nil) #writes out the Array hash *data* starting at the specified range *myRange* on the specified sheet. #the keys are used as column headers starting at the specified range. def save #saves the current workbook def addSheet(sheetName)# Adds a new worksheet to workbook def deleteSheet(sheetName)# Deletes a worksheet from the workbook -David --- I've been using the XLS interface class to get data for data-driven tests, but now I'd like to write data out to an Excel spreadsheet. Does anyone know if there is a list of the available methods for the XLS interface class? The documentation at http://wiki.openqa.org/display/WTR/Excel+interface+class mentions that you can write to Excel, but doesn't show the methods to use. I've checked the rdoc as well, but I don't see any information there either. Thanks! -Tiffany ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir no longer always waits for all frames to load
Bret, I've filed the issue in Jira as low priority. The ticket# is: WTR-165 Thanks for your help. -David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir no longer always waits for all frames to load completely (gem 1.5.1.1166)
I've been using the development gem 1.5.1.1166 which includes the re-written wait logic to test a complex SAP web application. The main content that I am automating is nested 4 frames deep. Up until this past Friday this version of watir seemed to handle waiting for all of the inner frames to load properly. Now however this wait logic isn't always waiting until the pages load completely which causes my scripts to fail. I don't think there have been any changes in the web app I'm testing which would cause this. I did happen to install the important/critical Microsoft security patches for June which could have effected watir? http://www.microsoft.com/technet/security/bulletin/ms07-jun.mspx Has any one else experienced this problem with the new wait logic not waiting quite long enough when there are many nested frames? I wish this was a public web-app so I could provide an example w/html to look at but it's not. Thanks! -David Brown ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir no longer always waits for all frames to load
Gems prior to 1.5.1.1166 would either give me the access denied errors as it tried to wait for the inner frames to load - or if those were suppressed, I had to put in a manual wait whenever I navigated to a new page: sleep 0.1 until some_element_on_inner_frame.exists?. After installing 1166 all of these delay problems were fixed... Until now. Now that this issue has surfaced I'm forced to put the manual delays in again. It is not a big deal to do this, but, it's always cleaner if watir handles the delays properly. -David From: Bret Pettichord [EMAIL PROTECTED] Brown, David wrote: I've been using the development gem 1.5.1.1166 which includes the re-written wait logic to test a complex SAP web application. The main content that I am automating is nested 4 frames deep. Up until this past Friday this version of watir seemed to handle waiting for all of the inner frames to load properly. Now however this wait logic isn't always waiting until the pages load completely which causes my scripts to fail. I don't think there have been any changes in the web app I'm testing which would cause this. I did happen to install the important/critical Microsoft security patches for June which could have effected watir? http://www.microsoft.com/technet/security/bulletin/ms07-jun.mspx Has any one else experienced this problem with the new wait logic not waiting quite long enough when there are many nested frames? What happens if you use an earlier Watir gem, before we rewrote the frame wait logic? Bret ___ 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
[Wtr-general] Excelent debugging tool - Unroller
All, I stumbled across this handy little debugging tool the other day when I was trying to find a tool that would display/trace the execution of my test script. This tool called Unroller will print out each line of code that is executed along with the values of the variable passed into and returned from methods. (optionally it will also keep track of local variables.) It is very helpful for quickly identifying exactly where your script died, and what values were causing it to choke. http://unroller.rubyforge.org/ For some reason I had to install the win32console gem as well to get it working: http://rubyforge.org/frs/?group_id=1766 Tip: when you invoke the unroller, you may want to exclude the common classes that you don't care about ie watir, string, array ... So that it only traces your code. For example: Unroller::trace(:max_depth = 5, :show_locals=true,:exclude_classes =[/Watir/,/String/,/Array/]) do # some watir test script code goes here end I hope some of you find this helpful! -David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir execution from webserver
I had the same issue where the script would execute but couldn't find any of the other 'required' files in the directory. To solve this problem, I had to add some code to the runner\app\controllers\runner_controller.rb specifying the test suite directory that the test should execute in. Now it is working Great! Here are the changes.: Def index ... suite_dir = T:/my test suite session[:suite_dir] = suite_dir #store it in the session so that it can be used by the runsuite action. ... End Def runsuite ... #added the argument: -Cdirectory ---cd to directory, before executing your script cmd = ruby -C#{session[:suite_dir]} [EMAIL PROTECTED] -f -v verbose #{session[:console_filename]} ... end -David Brown -- Message: 5 Date: Wed, 28 Mar 2007 14:28:56 CDT From: John Lolis [EMAIL PROTECTED] areed, I have noticed that paths in ruby are relative to file that is being executed ( i think ). This has caused a couple of head scratching moments on my part while i wonder they files will no longer load using relative paths. I'm not sure this is related to your problem, hope it helps. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Re-Usable Load Testing Example using Watir.
FYI - I've published a Re-Usable Load Testing Example under the Contributions section of the openqa watir website which demonstrates how to execute watir scripts concurrently to generate load and gather some basic performance testing metrics. http://wiki.openqa.org/display/WTR/Re-Usable+Load+Testing+Example -David Brown ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Excel Interface Class
I have noticed that this site (wiki.openqa.org) works fine with firefox but doesn't seem to work with internet explorer. -David From: swarna latha [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 06, 2007 6:49 PM To: Brown, David Cc: [EMAIL PROTECTED]; wtr-general@rubyforge.org Subject: Re:[Wtr-general] Excel Interface Class Hi, I am unable to access the links http://wiki.openqa.org/display/WTR/Excel+interface+class http://wiki.openqa.org/display/WTR/Excel+interface+classand http://wiki.openqa.org/display/WTR/FAQ and I think it would be of great help to me if I can! It gives me Page cannot be displayed error. I have been trying to access it since the last 2 days..:( Any ideas why? Thanks Billy for the code snippet pointer to clear cache issue. Thanks, Swarna. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Excel Interface Class - extend to openoffice/google spreadsheets
I currently don't have the time/motivation to extend the excel interface class to work with Open Office and Google spreadsheet, however, If someone really needs to do this it shouldn't be too difficult. Only the following methods of the XLS class contain excel specific commands that would need to be overridden: -Initialize()#opens an excel file -getRangebyLabel()#finds a range of data dynamically -getWorksheet()#finds a worksheet to use -get2DArray()#returns a 2D array of data based on a given range and worksheet name. -David Brown -- From: Paul Rogers [EMAIL PROTECTED] I use Open Office. Having the Excel reader is handy, but it obviously doesnt work for me. I started working on some code that would read open office spreadhseet files. It would be great if you could make it work on both, with the same interface, especially as things like firewatir and safari watir work well on non windows platforms. The open office format is an xml file in a zip, and its actually quite easy to work with. I can send you my code if you like Paul ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Excel Interface Class
I've posted an Excel Interface class which I've developed over the past few months on the Watir openqa.org site under contributions: http://wiki.openqa.org/display/WTR/Excel+interface+class This class provides simple methods for reading data records from Excel spreadsheets, hides the complexities of directly using ruby's win32ole library to interface with Excel, and makes it much easer to create data-driven Watir tests. I hope it will be as useful to others as it has been for me. -David Brown ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] saving screenshots with snagit
Thanks for help! -Dave - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=6361messageID=18083#18083 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] saving screenshots with snagit
Hello, I've found a couple posts that indicate that snagit's COM server can be used to capture screenshots while Watir runs tests. I've tried to implement something with this, but I am having trouble with the Autoscroll options. I have not been able to figure out how to set capture options except by using integers. However, I cannot find a reference for which integer corresponds to which option, so the process has been trial and error. What I have so far is below. When I view the resultant screen shots, they are not scrolled, so I cannot see the lower part of the web page: def screenCapture(client, environment, directory) # this method will use snagit to capture and save a screenshot to a directory require 'win32ole' # create snagit ole object: snagit = WIN32OLE.new('Snagit.ImageCapture') # set properties for the capture snagit.Input = 1 #capture a window snagit.Output = 2 #output to a file snagit.InputWindowOptions.SelectionMethod = 1 # select active window for capture # set the filename for the capture snagit.OutputImageFile.Filename = createScreenCaptureFilename(#{client}-#{environment}, directory) snagit.OutputImageFile.Directory = directory# set directy where filename will be saved snagit.OutputImageFile.FileNamingMethod = 1 # set naming method to fixed snagit.AutoScrollOptions.AutoScrollMethod = 0 # set autoscroll to vertical and horizontal snagit.OutputImageFile.ColorDepth = 5# set color depth to 8 bits # do the capture snagit.Capture # verify that capture is done, then return while !snagit.IsCaptureDone if snagit.IsCaptureDone then return end end return end Does anyone have a reference for snagit that shows which integers correspond to which options? snagit version: 7.1 thanks in advance for any comments, Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] key codes are always zero
Hi, I enjoyed using Watir, I have one problem. When automating tests, the text entered into text boxes does not fire key events properly in the IE DOM, the key codes are always zero. I am testing a browser plugin, that captures keystrokes when im doing debugging so I can set the plugin into certain modes from text entered. Ive tried modifying the source to generate the right codes but doesn't work. Is there a way to make it set the correct key codes? Regards David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Javascript Alert windows
Matt, The problem is that when the enabled_popup method was removed from watir.rb the definitions for GetWindows() definition wasn't moved with it. Afterwards, the definition for GetWindows was moved in the watir.rb file so that it is no longer found by enabled_popup. If you look in the watir.rb file for GetWindow and move those definitions into the enabled_popup.rb file then it should work fine. David Schmidt Matt Johnson wrote: On 10/5/06, *Cain, Mark* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: The JavaScript Alert, Confirm, Prompt, Security, File Save, File Download, File Upload, error message, and login (I think this is a complete list but there may be others) are all a special type of modal popup dialog window—there isn't a different one. In order to handle these types of popups you have to start another thread independent of your $ie thread OR you have to not block the process by using click_no_wait. There are two ways (that actually both use the WInClicker). The first one is listed below that works with the older versions of Watir. The second (I have found after using them both) is more reliable than the first but require you having a Watir version greater than 1079 because of some fixes to click_no_wait (can't remember the exact version). You can get them here: http://wiki.openqa.org/display/WTR/Development+Builds *_First method (works with Watir 1.4.x):_* def jsAlert(button, waitTime = 3) w = WinClicker.new longName = $ie.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName}\\watir\\clickJSDialog.rb #{button} #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end Then, before the button you want to click that generates the popup, add in: jsAlert(OK, 3) ie.button(:name, woohoo).click # This is the button you want to click that generates the popup *_Second Method (faster and more reliable):_ * require 'watir\contrib\enabled_popup' Your code $ie.button(Button Label Text).click_no_wait # use click_no_wait to click the button that invokes the JS Alert $ie.button.click_no_wait hwnd = ie.enabled_popup (5) # get a handle if one exists if (hwnd) # yes there is a popup w = WinClicker.new w.makeWindowActive(hwnd) # OK or whatever the name on the button is w.clickWindowsButton_hwnd(hwnd, OK) end NOTE: If you are using IE7 then the title on the JS Alert box is different then IE6+ so you will need to alter you WinClicker.rb file for either method. \ruby\lib\ruby\site_ruby\1.8\watir\WinClicker.rb Lines 113 and 144. IE6 = Microsoft Internet Explorer IE7 = Windows Internet Explorer Hope this helps, *--Mark* ___ Wtr-general mailing list Wtr-general@rubyforge.org mailto:Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general Hello, I have been trying to use the second method described above with no success. I am trying to clear a security dialog that appears after clicking a Sign In button. I can see that the button gets clicked, then the script blocks. If I kill the script ( by closing the browser, or whatever ) I get this error message: c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1100/./watir/contrib/enabled_popup.rb:10:in `enabled_popup': uninitialized constant Watir::PageContainer::GetWindow (NameError) from c:/ruby/lib/ruby/gems/1.8/gems/watir- 1.5.1.1100/./watir/contrib/enabled_popup.rb:9:in `until_with_timeout' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1100/./watir.rb:210:in `wait_until' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1100/./watir.rb:210:in `until_with_timeout' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1100/./watir/contrib/enabled_popup.rb:9:in `enabled_popup' from C:/ruby/mattj/scanmus/scanmus3.rb:79 Can anyone tell me what the problem is, or how I can debug this further? Why is this not initialized? Does that mean I have some kind of path or other environment problem. I am using WinXP SP2, ruby 1.8.2 (2004-12-25) [i386-mswin32], watir 1.5.1.1100. Thanks in advance. -- MattJ [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Javascript Alert windows
Does Watir have a way of processing _javascript_ Alert windows, by clicking the OK button to dismiss the window? The code that invokes the window issues an alert call with no window handle. I did not find anything on this in the online docs or in the email dist. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Javascript Alert windows
Clever code. My problem is slightly different. I am testing a product that uses a web based GUI, by navigating to all GUI controls and collecting data for validation comparisons. This product generates the _javascript_ alert windows to kindly prompt the user that some action has been completed. They lock up the screen until something clicks the OK button on the _javascript_ alert window. I want to code the OK button click for this window, which was opened by the product. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Reed Sent: Wednesday, October 04, 2006 1:40 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] _javascript_ Alert windows David, I remember this being in the FAQ and forum posts, but I haven't been in a while -- maybe it was removed (I can't check at the moment). First you define your script that closes the window (I called it jsAlert). def jsAlert(button, waitTime = 3) w = WinClicker.new longName = $ie.dir.gsub(/ , \\ ) shortName = w.getShortFileName(longName) c = start ruby #{shortName}\\watir\\clickJSDialog.rb #{button} #{waitTime} puts Starting #{c} w.winsystem(c) w=nil end Then, before the button you want to click that generates the popup, add in: jsAlert(OK, 3) ie.button(:name, woohoo).click # This is the button you want to click that generates the popup Thanks, Adam Reed RelocationCentral by CORT From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Munns Sent: Wednesday, October 04, 2006 12:19 PM To: wtr-general@rubyforge.org Subject: [Wtr-general] _javascript_ Alert windows Does Watir have a way of processing _javascript_ Alert windows, by clicking the OK button to dismiss the window? The code that invokes the window issues an alert call with no window handle. I did not find anything on this in the online docs or in the email dist. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Fwd: Managing the Watir Project -- Wikipedia entry
Bret Pettichord wrote: On 9/26/06, *Sun* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Regarding documentation, please see: http://en.wikipedia.org/wiki/Watir Thank you for taking the time to do this. I do have a comment that i hope you won't take personally. I find code like this to be rather embarrassing: # To handle general popups, use WinClicker. ie.button(:name, btnG).click_no_wait # ensure popup won't block Watir hwnd = ie.enabled_popup(5) # get a handle if one exists if (hwnd)# yes there is a popup w = WinClicker.new w.makeWindowActive(hwnd) w.clickWindowsButton_hwnd (hwnd, Yes) # click the Yes button end I keep meaning to write a simpler way of doing this kind of thing, but then never really have the time to follow through. In my opinion, The code should actually look like this: ie.button(:name, btnG).click_no_wait # ensure popup won't block Watir ie.dialog.button('OK').click I disagree that the code *should* look like that. That is nice code if you *know* that a dialog has appeared. The problem is that after performing a click_no_wait you don't know what kind of popup may appear (or even IF one will appear). It could be an IE security warning, or a Javascript dialog, or a modal dialog. I have sites that I use Watir for that DO just that type of thing. After clicking a button I may get a Javascript popup with an error warning, or I may get a modal dialog with additional input fields. The reason I wrote enabled_popup is because Windows uses an enabled_popup call to give you a window handle to *whichever* popup window is active. I often use it in combination with Watir::until_with_timeout to detect when either a popup has appeared OR the browser has finished loading (with no popup). If a popup is detected then you can do various tests to determine which type of popup is present and handle it as needed. Also, since we get error messages in Javascript popups we also need to be able to access any text in them, which WinClicker also provides. I did begin implementing an interface like this in watir once (see watir/dialog.rb and unittests/dialog_test.rb), but didn't finish. It used the Autoit library, which i also now think is not the best approach. I would love to see someone finish this work. Clearly, this is a common problem for Watir users, but my view is that the problem is not a lack of documentation, but rather a hard-to-user interface. I would love to get this cleaned up for the full release of 1.5. Bret Perhaps you'd find more people willing to finish the work if their work wasn't partially merged without notice. Or perhaps people would be more willing to contribute if their functioning code, used by other Watir users, wasn't removed from Watir without notice. Maybe folks would be happy to contribute their hard work if they weren't summarily removed from the commit group after they admitted to breaking a method used by some users (searching for :id by regexp) but for which there were NO unit tests AND THEN FIXING THAT BUG AND ADDING IN THE MISSING UNIT TESTS. Referring to their code as unreliable with no evidence of any problem with that code or any failures of any unit tests, especially when the problem someone was having was not related to that code also shows a certain pre-disposition towards that code. I've seen another list member censored by having all of HIS posts moderated after he made some statements disagreeing with some of the decisions being made by the Watir developers. I believe it's better to have code that solves people's problems, and in making that code available to them as soon as possible rather than waiting to release a new version until the code is finished or perfect. This is because almost NO code is ever finished or perfect. Different people have different uses for Watir, and need different functionality. Just because a particular method isn't useful for one user doesn't mean it isn't required by other users. The best way for code to be tested by the community and peer reviewed is to have it USED by that community in development builds. I'm not saying my contributions have all been perfect or the best they could be, but my code is working in production systems, and working well. I think I've also shown a willingness to promptly fix any problems that are shown. Sorry to vent, but I'm the author of the enabled_popup() method (which has been removed from watir.rb) and the one that helped Sun solve his problem when he presented it to the list. Statements welcoming contributions aren't entirely consistent with the treatment those contributions receive. I fully expect comments explaining that my code was inappropriate or didn't work, but I'll let my code and methods stand for themselves and I welcome peer review, comments and improvements to my contributions. David Schmidt
[Wtr-general] watir and Javascript alert windows
I am building test automation for a product that displays _javascript_ alert windows, for which no window handle exists. They act like modal windows since they wait for a user mouse click on a button (and pause the automation run). Is there a way with watir to simulate the button click? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] nested tables
I've done a lot of web scraping, where we have to deal with whatever HTML the developer hacked together. Nested tables without id's or name's can be a pain, but they can be dealt with. The methods may be different depending on which version of Watir you're running though. I'm using 1.5 from trunk here, and I recommend using one from trunk, even though they're not officially released yet. In these cases, IRB is your best friend. Here I've opened the browser to table1.html in the unittests\html directory. I then start up IRB and connect to that browser: C:\Documents and Settings\davidsirb irb(main):001:0 require 'watir' = true irb(main):002:0 include Watir = Object irb(main):003:0 ie = IE.attach(:title, /Test/) [...] Next, we look to see what tables we have: irb(main):008:0 ie.show_tables Found 6 tables 1 id= rows=2 columns=2 2 id=t1 rows=5 columns=1 3 id=t2 rows=2 columns=2 4 id= rows=1 columns=2 5 id=body_test rows=5 columns=1 6 id=pic_table rows=1 columns=4 = nil irb(main):009:0 Here we'll look for the nested table example. Looks like table 3 matches the nested table on the screen. Note that table 4 is the table *inside* table 3! We can confirm these guesses by showing the HTML for each table: irb(main):010:0 ie.table(:index, 3).html = \r\nTABLE id=t2 border=1TBODY\r\nTR\r\nTDcell 1 \r\nTDcell2 \r\nT R\r\nTD\r\nTABLE\r\nTBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY /TABLE\r\nTDNormal /TR/TBODY/TABLE irb(main):011:0 ie.table(:index, 4).html = \r\nTABLETBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY/TABLE irb(main):012:0 Sure enough, you can see table 4 there in the middle of table three. The reason this is important is because you can use indexes to find cells in a table: irb(main):013:0 ie.table(:index, 3)[1][1].text = cell 1 The trick is that the embedded tables are counted as part of the containing table. This is why the row_count for table 3 shows *3* rows instead of two: irb(main):014:0 ie.table(:index, 3).row_count = 3 It's counting it's own two rows, plus the one row in the containing table. Row 3 is the table 4's row 1, but though row_count reports 3 rows, it won't let you ACCESS row 3, because it's really in table 4! irb(main):016:0 ie.table(:index, 3)[2][1].text = nest1nest2 irb(main):017:0 ie.table(:index, 3)[2][1].html = \r\nTDTABLE\r\nTBODY\r\nTR\r\nTDnest1\r\nTDnest2/TR/TBODY/T ABLE irb(main):018:0 ie.table(:index, 4)[1][1].text = nest1 irb(main):019:0 ie.table(:index, 4)[1][2].text = nest2 irb(main):020:0 ie.table(:index, 3)[3][1].html WIN32OLERuntimeError: Unknown property or method `2' HRESULT error code:0x80020006 Unknown name. from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `[]' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `row' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3140:in `[]' from (irb):20 irb(main):021:0 ie.table(:index, 3)[3][1].text WIN32OLERuntimeError: Unknown property or method `2' HRESULT error code:0x80020006 Unknown name. from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `[]' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3193:in `row' from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1077/./watir.rb:3140:in `[]' from (irb):21 irb(main):022:0 That last row must be accessed via table 4. There have been some discussions about fixing this inconsistency and I've argued towards accuracy where row_count would only report the rows in it's OWN table, and sub-tables would be accessed for their row count, but others have been afraid of breaking existing tests which already account for the inaccurate count. Hope this helps you address the cells in your nested table situation. David Schmidt Vincent Predoehl wrote: I'm writing scripts to test a web site I didn't write myself. This web site has nested tables … not all of them have names … noobs. How do you access nested tables in watir? I've tried everything and am at my wit's end. I'm about ready to just grep the source code for the links, but I'd rather not do that. -- Vincent ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] What happened to the enabled_popup method?
Charley Baker wrote: Mark, It's still available, but in the watir/contrib directory. In order to use it, add require 'watir/contrib/enabled_popup' to your scripts. This is still a development version and so there will be some bumps along the way. Sorry about the confusion, I'll try to make sure changes are documented along the way to the next release. -Charley As the author of the enabled_popup() method I'd like to argue that it remain in the main Watir code. The enabled_popup call will give you the window handle of ANY type of popup, so it is very useful when a page may or may not open a popup window, and the user doesn't know whether that window will be a modal dialog window or a Javascript or IE popup. The functionality is already in the ModalDialog#find_modal_from_window method, so no code is being saved (in fact, my original ModalDialog class used enabled_popup to determine if a popup window was showing). This function is of general use and won't cost much in terms of code size, so why not let it remain? David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir Q's
I want to invoke a modal dialog window and navigate through its buttons, radio buttons, and lists. I am using watir 1.5.1081. The object that launches it is described as follows: Active Element: [TD], Frame: [fraBanner], Index: [29] TD IMG height=30 src="" width=69 IMG height=30 src="" width=97/TD Based on what I see in the watir unit tests, I have tried: ie.modal_dialog( :title, /Modal Dialog Partial Title/ ) = result is a watir timeout, even when I set timeout value at 60s It appears that the window is never found this way. Any suggestions? Once the modal dialog window is launched, if I want to click the OK button, is this the correct way? ie.button( :value, OK ).click Dave ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir-1.5.1.1081.gem and popups
Brian, The modal_dialog method uses a Win32 call that locates any popup window using your current IE window's handle (HWND). I had originally coded the (:hwnd, hwnd) parameters in addition to the version with no parameters, but they really do the same thing since there can only be *one* active popup at any time (though a modal dialog can bring up it's OWN modal dialog, but the second one will then become the only one you can attach to). Once you've attached to a modal dialog your second question is easy. You operate on a modal dialog the *same* way you'd operate against your normal IE window. This is because a modal dialog uses the same DOM model and loads from an HTML file. The hard part about modal dialogs was that there was no easy way to attach to them and get a good handle to the DOM, but I found some special code written by Yaxin Wang which does some fancy C++ casting to give us the same type of handle. Javascript or browser popups are different as they aren't based on HTML, so other methods are required to handle those, but once you attach to them, modal dialogs are easy! David [EMAIL PROTECTED] wrote: Hey In that case, how do I fetch a ModelDialog instance of the popup after calling click_no_wait on the IE instance? -Original Message- From: Charley Baker [EMAIL PROTECTED] Sent: Fri, September 15, 2006 7:25 To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] watir-1.5.1.1081.gem and popups You've pretty much answered your own question - only null and :title methods are supported. modal = ie.modal_dialog # or use the :title location method to find by title modal.close Look at modal_dialog_test.rb in the unit tests if you need more information and examples. -Charley On 9/15/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi Could some please explain how to find and close a modal dialog using watir-1.5.1.1081.gem. When I try to find the dialog using the line 'ie2 = ie.modal_dialog(:hwnd, hwnd) ' ruby returns the error 'Only null and :title methods are supported (ArgumentError)' Thanks ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] watir-1.5.1.1081.gem and popups
It's been a while, but I think I found the code in WET or perhaps in someone's blog, but in any case my statement here was to acknowledge that I didn't write that code, and to give credit to the author. David Bret Pettichord wrote: David Schmidt wrote: but I found some special code written by Yaxin Wang which does some fancy C++ casting to give us the same type of handle. David, It seems funny to hear that you found it. This was the code that Yaxin wrote at my request and to my specifications and contributed to Watir for this purpose. We were both with ThoughtWorks at the time. Using Yaxin's code, I wrote the original modal_dialog method that allowed us to access this dialog via Title, and then you enhanced this so that an argument was unnecessary. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] WIN32OLERuntimeError: unknown property or method
Jason, check out http://forums.openqa.org/thread.jspa?threadID=4012tstart=0 for a routine I use to wait for a page to load, checking for possible popups at the same time. It uses Watir::until_with_timeout. See if that helps. David Jason Alexander wrote: Doing some Googling, it appears that this has to do with the page still loading? Which makes sense, I have a few elements that are causing the page to “postback” (mechanism in ASP.NET). Assuming that’s the problem, what’s the best solution in most cases? I saw where there was some talk of a wait_until in Jira, but what can I do meanwhile? Thanks, -Jason ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir 1.5 and attaching to windows problem
Has anyone discovered a solution to the following? I built a test tool with Ruby/Watir (1.4). When I upgraded to Watir 1.5.1.1081 so that I could control modal dialog windows, suddenly the watir attach_browser_window call is unable to locate the main IE window by title. I tried other title names with no success. I am using Ruby 1.8.2.15, IE 6.0.3790.1830, Windows 2003 SP1.The results of running the Watir unit tests indicate 19 failures, but none related to window attaches: 1) Failure: test_Button_click_only(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:91]: false is not true. 2) Failure: test_button_click(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:101]: false is not true. 3) Failure: test_button_using_default(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:86]: false is not true. 4) Failure: test_SuccessMessage(TC_CSS) [unittests/../unittests/../unittests/css_test.rb:53]: false is not true. 5) Failure: test_onClick(TC_CheckBox) [unittests/../unittests/../unittests/checkbox_test.rb:43]: false is not true. 6) Failure: test_divs(TC_Divs) [unittests/../unittests/../unittests/div_test.rb:20]: false is not true. 7) Failure: test_objects_in_div(TC_Divs) [unittests/../unittests/../unittests/div_test.rb:74]:button1 expected but was . 8) Failure: test_objects_in_span(TC_Divs) [unittests/../unittests/../unittests/div_test.rb:140]: button1 expected but was . 9) Failure: test_spans(TC_Divs) [unittests/../unittests/../unittests/div_test.rb:86]: false is not true. 10) Failure: test_JS_Events(TC_Fields) [unittests/../unittests/../unittests/textfields_test.rb:150]: keypresskeydownkeypresskeyup expected but was . 11) Failure: test_hidden(TC_Hidden_Fields) [unittests/../unittests/../unittests/form_test.rb:239]: 44 expected but was. 12) Failure: test_Iframe(TC_IFrames) [unittests/../unittests/../unittests/frame_test.rb:101]: false is not true. 13) Failure: test_frame(TC_NestedFrames) [unittests/../unittests/../unittests/frame_test.rb:86]: false is not true. 14) Failure: test_onClick(TC_Radios) [unittests/../unittests/../unittests/radios_test.rb:53]: false is not true. 15) Failure: test_selectBox_select2(TC_Selectbox) [unittests/../unittests/../unittests/select box_test.rb:139]: false is not true. 16) Failure: test_select_list_select_using_value2(TC_Selectbox) [unittests/../unittests/../unittests/selectbox_test.rb:171]: false is not true. 17) Failure: test_dynamic_tables(TC_Tables) [unittests/../unittests/../unittests/table_test.rb:59]: 6 expected but was 5. 18) Failure: test_simple_table_buttons(TC_Tables_Buttons) [unittests/../unittests/../unittests/table_test.rb:208]: false is not true. 19) Failure: test_table_from_element(TC_Tables_Buttons) [unittests/../unittests/../unittests/table_test.rb:279]: false is not true. 180 tests, 965 assertions, 19 failures, 0 errors ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir 1.5 and attaching to windows problem
Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/modal_dialog_test.rb:11:in `setup' 16) Error: test_modal_dialog_use_case_invalid(TC_ModalDialog): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/modal_dialog_test.rb:11:in `setup' 17) Error: test_double_modal(TC_ModalDialog): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/modal_dialog_test.rb:11:in `setup' 18) Error: test_simply_attach_to_new_window(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 19) Error: test_attach_to_new_window_using_separate_process(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 20) Error: test_attach_to_new_window_using_click_no_wait(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 21) Error: test_click_no_wait_works_in_a_container(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 22) Error: test_attach_to_slow_window_works_with_delay(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 23) Error: test_attach_to_slow_window_works_without_waiting(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 24) Error: test_attach_timesout_when_window_takes_too_long(TC_NewWindow): WIN32OLERuntimeError: navigate OLE error code:800700AA in Unknown No Description HRESULT error code:0x80020009 Exception occurred. ./../watir.rb:1613:in `method_missing' ./../watir.rb:1613:in `goto' ./unittests/attach_to_new_window_test.rb:12:in `setup' 35 tests, 21 assertions, 4 failures, 20 errors -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bret Pettichord Sent: Wednesday, September 13, 2006 11:01 AM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] Watir 1.5 and attaching to windows problem I have not seen these errors before. If anyone else sees these also, please report. David, It look like you are running the core_tests.rb. Ruby windows_tests.rb to run the unit tests for IE.attach. Bret David Munns wrote: Has anyone discovered a solution to the following? I built a test tool with Ruby/Watir (1.4). When I upgraded to Watir 1.5.1.1081 so that I could control modal dialog windows, suddenly the watir attach_browser_window call is unable to locate the main IE window by title. I tried other title names with no success. I am using Ruby 1.8.2.15, IE 6.0.3790.1830, Windows 2003 SP1. The results of running the Watir unit tests indicate 19 failures, but none related to window attaches: 1) Failure: test_Button_click_only(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:91]: false is not true. 2) Failure: test_button_click(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:101]: false is not true. 3) Failure: test_button_using_default(TC_Buttons) [unittests/../unittests/../unittests/buttons_test.rb:86]: false is not true. 4) Failure: test_SuccessMessage(TC_CSS) [unittests/../unittests/../unittests/css_test.rb:53]: false is not true. 5) Failure: test_onClick(TC_CheckBox) [unittests/../unittests/../unittests/checkbox_test.rb:43]: false
Re: [Wtr-general] Watir 1.5 and attaching to windows problem
I uninstalled all Ruby and Watir versions, installed Ruby 1.85-21 and Watir 1.5.1.1081. Running the Watir unit tests (ruby window_tests.rb) cause the IE information bar to keep prompting me allow blocked content? which appears to mess up the unit tests (failures and errors). Various attempts to disable this prompt have not been successful. How do you get these unit tests to run cleanly? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bret Pettichord Sent: Wednesday, September 13, 2006 1:44 PM To: wtr-general@rubyforge.org Subject: Re: [Wtr-general] Watir 1.5 and attaching to windows problem It seems like you are getting a mix of Watir 1.4 and 1.5. If you used the one-click installer for 1.4, you need to uninstall Watir (or just uninstall Ruby) and then install 1.5. 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] Handling (Browser Security Driven?) Modal Dialog - Resolved
Glad to help. Sun wrote: Problem resolved. First -- I don't actually know if this is, or is not, a modal dialog, since the: if (modal = ie.modal_dialog(:hwnd, hwnd)) statement cannot be parsed (because apparently, even in the 1081 code branch the :hwnd parameter is not recognized for this method call.) Since there can only be one modal dialog in control at any one time, you don't need *any* parameters to connect to a modal_dialog as long as there is only one IE with a modal dialog open at any time. However, because you *can* have two IE processes running at once I had coded in the ability to connect directly to the proper modal dialog window that YOUR IE process opened. However, that code was removed and I cannot replace it. However, this window that you're seeing is NOT a modal dialog. IE has a number of different kinds of popup windows. One is the modal dialog which loads a normal HTML file and can even take inputs which are passed back to the calling window. Once you attach to a modal dialog you can treat them like any other IE window and perform normal Watir commands to read the HTML and/or fill any forms and click the dialog's buttons. The other type of popup is a Javascript, or Security popup. They do not contain HTML and they cannot be manipulated with normal Watir commands. The WinClicker class in winclicker.rb has methods which allow you to perform some operations on a Javascript popup including reading static text and clicking on buttons by button label. Since *those* are the methods that worked for you below I know that your window was a Javascript and not a modal dialog. Both types of popup window will block if you use click on the button that creates them. This means that Watir's click() method will never return until the popup is closed. This is why you need to use the click_no_wait() method to click the button that opens the popup. Click_no_wait starts up another Watir process which clicks the button (and blocks). This leaves your main Watir task running so that it can attach or handle the popup. However, I resolved the problem by brute force (non elegantly.) This is how I did it. While some might consider it brute force or non-elegant, it is the method we must use to handle these popups. This is because the click that creates the popup will block, and because IE doesn't give Watir a way of easily controlling these popups. === require 'watir' require 'test/unit' class TC_article_example Test::Unit::TestCase def test_search # open the IE browser ie = Watir::IE.new # steer to google ie.goto('http://www.google.com/') # load the search field ie.text_field(:name, q).set(pickaxe) #Ensure popup won't block Watir ie.button(:name, btnG).click_no_wait #Handle the popup hwnd = ie.enabled_popup(5) if (hwnd) #yes there is a popup p hwnd w = WinClicker.new w.makeWindowActive(hwnd) w.clickWindowsButton_hwnd(hwnd, Yes) end # insert pause or it doesn't work... sleep 3 # Validate response assert(ie.pageContainsText(Programming Ruby)) end end === The key things. 1st, I used the click no wait feature: ie.button(:name, btnG).click_no_wait Required to be able to continue to execute commands in your original Watir script. 2nd, I made use of the new enabled_popup functionality to get hwnd. The enabled_popup() method uses the GW_ENABLED_POPUP option of the GetWindow() call in Windows USER32.DLL to locate any popup window associated with the current window. Watir can then use that window handle (HWND) to manipulate the popup. 3rd, I used WinClicker to access and kill the security popup Correct. Since it wasn't a modal_dialog this is the best way to clear the popup. There are even calls in WinClicker which will retrieve any static text displayed in the popup window before you click the OK button to clear it. I've used this to retrieve error messages being displayed. 4th and finally, I had to insert that sleep statement or...it would fail with this error on the assert call: nil is not true. Why this should occur I don't know and I find troubling...perhaps someone can explain why this works. When the popup window is closed then control is returned to the original IE window. Since a popup window may be opened by a window you are *leaving* your assert started looking for the text before the page containing that text had finished (or perhaps even *started*) loading. Because of that you may not have even had a valid page when you performed the assert. Try putting in an @ie.wait after clicking the button and before the assert and see if that helps. David Schmidt ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Handling (Browser Security Driven?) Modal Dialog
Sun wrote: Yes...the problem I have is that I have a corporate browser. I have in fact checked this so that it should not reappear but it does anyway. Corporate IT doesn't let us change the security levels for the browser so...that is probably why the popups are forced. OK, thank you for the suggestion. I have implemented it. Problem now is, I get this message: undefined method `enabled_popup' for #Watir::IE:0x2c61aa4 Presumably I am missing a library somewhere? I should be requiring something that I am not? But as I mentioned in the base note, I have installed the current Ruby (1.8.4-20 stable), and the development gem for Watir (watir-1.5.1.1065.gem) so...here is the complete script text (which I am running in freeride): The enabled_popup() call wasn't added to the development trunk until about version 1079. Version 1081 is now available at http://wiki.openqa.org/display/WTR/Development+Builds and that version has enabled_popup(). David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] right click???
This has nothing to do with the performance enhancements, and aside from the bug where I didn't check for a regexp being fed to getElementById() (which I fixed) I haven't seen any signs of that performance fix being unreliable. All tests pass, including the ones I added to check for being able to use a regexp to match an :id, which weren't there or I would have caught the bug the first time. The problem in this case is exactly what it says. A DIV element in the DOM doesn't *have* a fireEvent OLE call. (I just brought up IRB, attached to an IE window open to unittests/html/div.html, assigned the first DIV element to a variable and then had it show me all the valid OLE methods: irb(main):001:0 require 'watir' = true irb(main):002:0 include Watir = Object irb(main):020:0 ie = IE.attach(:title, /Div/);nil = nil irb(main):021:0 d = ie.div(:id, 'div1');nil = nil irb(main):022:0 d.document.ole_methods = [setAttribute, getAttribute, removeAttribute,... No fireEvent, as the error message below stated. Željko, are you sure that the right click event was in the DIV and not in another element inside of the DIV? David Schmidt Bret Pettichord wrote: I believe that this is bug introduced by the recent performance enhancement to Watir that needs to be backed out until it can be made more reliable. Unrelated to the error message, there is on rightclick javascript event. I read my JavaScript book on the topic and it said that the event is onClick but that you have to set the button bits on the event. I'm not sure exactly how this would be done. Bret Zeljko wrote: This is out of my league. Anybody familiar with this error message? Željko ie.div(:id, detailProposal0610760).fire_event(rightclick) It highligts it like it wants to do something but never acts as a right click. This is the message in the prompt that I get if that helps. C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2039:in `method_missing': fireEvent (WIN 32OLERuntimeError) OLE error code:80070057 in htmlfile Invalid argument. HRESULT error code:0x80020009 Exception occurred. from C:/ruby/lib/ruby/site_ruby/1.8/watir.rb:203 :in `fire_event' from ../test/test2.rb:180 - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4007messageID=11218#11218 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Handling (Browser Security Driven?) Modal Dialog
Cain, Mark wrote: Will this handle modal windows and JS popups now? Has that modal window code been merged into the main branch now? --Mark It still doesn't have all of the functions I added to the modal_dialog branch, like Element#visible?, but it should have most of the modal_dialog support working and the IE.enabled_popup call is now in so you can tell when *any* type of popup is being displayed. In addition, click_no_wait now works on elements in a sub-frame. David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] right click???
I have been actually using a variation of that and it wont work ie.div(:id, detailProposal0610760).fire_event(rightclick) It highligts it like it wants to do something but never acts as a right click. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4007messageID=11071#11071 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Drag and Drop
If I did mouse down and mouse up commands somehow, couldnt I in theory figure out a way to drag and drop? - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4005messageID=11073#11073 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] right click???
I posted what I get in the prompt in the post above yours(added it in) It should bring up a small pop up window smiliar to if you right click any where on a webpage, with just different options. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4007messageID=11076#11076 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] How to discover and address items within nested frames.
Here's a small hint which can make your Watir code more readable and a bit faster. When you're identifying an element that may may be many frames deep, or even deep within a single frame, save the element into a variable. This way Watir doesn't go through the entire search process every time you use the element: myframe = ie.frame(:name, frame3).frame(:name, frame4).frame(:name, tframe1) puts myframe.html myframe.select_list(:name, fromedate).flash Your Watir code also ends up a lot more readable without the very long lines :-) David haggard wrote: Ah, here's a tip. Use the 'html' function to get the string that Watir sees. Once that is present then things become much clearer. In the previous example, it now becomes obvious what was wrong and how to address the 'fromdate' combo. brbr puts ie.frame(:name, frame3).frame(:name, frame4).frame(:name, tframe1).html br ie.frame(:name, frame3).frame(:name, frame4).frame(:name, tframe1).select_list(:name, fromdate).flash brbr However, I'd still be grateful for further tips from those of you who know so much more than I about how to discover who to navigate about framed ASP pages. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir on Rails
Dave, Very nice! I notice that your example at http://watir-on-rails.rubyforge.org/ tests the URL for the local development Rails app on the default port (http://localhost:3000/). Does your plugin start the web server when you do the rake test:watir or do you have to ensure that the web server is already running? David Schmidt Dave Hoover wrote: I have just released a Ruby on Rails Plugin that allows for easy Watir testing in Rails. To install the plugin in your Rails project, execute ./script/plugin install svn://rubyforge.org/var/svn/watir-on-rails You can then use the generator to get you started on writing your first Watir on Rails test... ./script/generate watir SuccessfulLogin Your Watir tests will live in test/watir and can be executed from Rake like this... rake test:watir In your Watir tests you will have access to all the standard Rails testing conveniences, such as fixtures and ActiveRecord APIs. More information can be found at http://watir-on-rails.rubyforge.org/ Watir on Rails supports both Watir::IE and Watir::Safari. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] right click???
Here I go with another newb question, how can you do a right click? instead of .click would it be .rightclick? I do look for the answers before I post these things, but im lost again. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=4007messageID=10999#10999 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Click Link In Table Based on Row and Column Numbers
Be warned that this method will only work if there are no sub-tables contained in the rows searched. This is because row_count will show the number of rows in a single table, but ie.table[row][column] will find every row located in OR BELOW that table. So, if the cell at ie.table[1][1] contained a table with 2 rows then ie.table[2][1] would be the first row of the sub-table, NOT the 2'nd row in ie.table. David Attebery, Bill wrote: One way I can think of - not necessarily the best, based on some posts I've seen there seems to be the concept of cell in 1.5 that I haven't been able to try. But for what it's worth I think this would work. if ie.table(:index, 2).exists? row_count=ie.table(:index, 2).row_count unless row_count == nil for i in 1..row_count #assumes you're looking for data that is displayed in the browser as text, use a different attribute if not #could also use regexp ie.table(:index, 2)[i][1].text ~= /ColumnData/ if (ie.table(:index, 2)[i][1].text == 'Column1Data' and ie.table(:index, 2)[i][2].text == 'Column2Data') ie.table(:index, 2)[i][3].click break end end end else puts table not found end -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of MR Sent: Wednesday, September 06, 2006 9:38 AM To: wtr-general@rubyforge.org Subject: [Wtr-general] Click Link In Table Based on Row and Column Numbers This is a rephrased question because i realized what i was asking before didn't capture what i was trying to do. Basically, I need to click on a link that may or may not exist in a table. The table doesn't have an ID, but I do know that it is the second table on the page. I need to indentify the possible link by contents in the same row. For example, I want to search the table for rows that contain 'Column1Data' and 'Column2Data' in columns 1 and 2. Once I find this data, I want to click on a link in the same row, but in column three IF it exists. This link may not exist. Thanks again ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I am a newb
Doesnt work - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10851#10851 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I am a newb
I cant pull up irb. I am in the command prompt, it is defaulted at C:\Documents and Settings\user I have typed in irb here, I have changed the directory to just C:\ and tried. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10853#10853 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I am a newb
1 javascript:logout(); Log Out 2 http://www2.lymba.com/test/propmen3/documents/Pana lyst_UserGuide.pdfUser Guide (PDF) 3 http://www2.lymba.com/test/propmen3/documents/Pana lyst_UserGuide.pdfUser Guide 4 http://www2.lymba.com/test/propmen3/documents/Pana lyst_TechnicalDescription.pdfTechnical Description and Algorithms 5 http://www2.lymba.com/test/propmen3/documents/Pana lyst_Assumptions.pdfPurpose and Assumptions 6 javascript:showSessionDialog('Restore'); Restore Session 7 javascript:buildClusters(); Create Panels 8 javascript:backHome(); New 9 javascript:revertPanels(); Revert Panels 10javascript:submitSearch(document.getElementById('s earchTypeSelect').value,%20document.getElementById('searchInput').value);Search 11undoButton javascript:undo(); Undo 12redoButton javascript:redo(); Redo 13javascript:clearReviewers(); Clear Reviewers 14javascript:assignReviewers(); Match Reviewers 15javascript:showExportDialog(); Export Data 16javascript:showSessionDialog('Save'); Save Session 17javascript:showSessionDialog('Restore'); Restore Session 18overviewModeLinkProposalsjavascript:setOverviewMode('Proposals ');Proposals 19overviewModeLinkReviewersjavascript:setOverviewMode('Reviewers ');Reviewers 20detailModeLinkProposalsjavascript:setDetailMode('Proposals'); Proposals 21detailModeLinkReviewersjavascript:setDetailMode('Reviewers'); Reviewers 22detailModeLinkAssignmentsjavascript:setDetailMode('Assignments ');Assignments 23detailModeLinkGridjavascript:setDetailMode('Grid'); Grid 24javascript:moveInspectedProposal(); Move 25javascript:moveInspectedReviewer(); Move 26sessionDialogCanceljavascript:hideSessionDialog(); Cancel 27javascript:exportData('clusters'); Export All Panels With Proposals 28javascript:exportData('reviewers'); Export Reviewer Data 29javascript:exportData('panels'); Export All Panels with Assignments 30sessionDialogCanceljavascript:hideExportDialog(); Cancel = nil irb(main):012:0 OK I hope this helps, I want to click or select the link on line 30. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10855#10855 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] I am a newb
Ok so I just started using ruby and watir, when I say just started I mean no programming experience. The company I work for has me using/learning Watir. I can't make it click a button. I can make it click other buttons though. The software we developed doesnt use buttons per say, but something using href's and that such. I was wondering when you tell watir to ie.link(:text, Cancel).click , does it search the page source for just cancel? We have several so-called buttons named cancel. Does watir just hit the first cancel? If so how do I make it hit this specific cancel? Any thought are much appreciated. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10762#10762 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I am a newb
I want to say thanks to everyone, I am trying to understand. With the $ie.button(:index, 2).click command how does it know that it is looking for Cancel. This is the html source I am trying to pull from: a class=right button id=sessionDialogCancel href=JavaScript:hideSessionDialog();Cancel/a I have exhausted all of my ideas, I havent tried to do the $ie.button(:index, 2) command yet. I am going to buy a book on Ruby, but college textbooks come first. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10774#10774 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] I am a newb
Apparently I need more help than thought. I have tried all of the ideas every one has given me(thank you). I am still unclear on how to use index or flash method. The button or link I am trying to get to, I have done many others just like it, but for some reason I cant get it to press cancel this time. I have been using ie.link(:text, Export Data).click format, but I figure the one I am trying to do watir is grabbing one of the first Cancel's in the source. In the ruby prompt, it will go through and act like everything went smoothly. It is laid out the same way as others, but I dont know. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=3917messageID=10779#10779 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Modal Dialogs via Remote Desktop on Win XP
Dara, We routinely run web scraping sessions using Watir on remote Win2003 server and XP Pro machines, and a number of our sites have modal dialog and/or Javascript popups. However, we always run the scraping sessions on the console session and have set up our remote desktop sessions to show that same console. (Normally when you remote desktop in you get a new, virtual display that doesn't show the current console contents.) From http://blogs.msdn.com/sameerm/archive/2004/09/01/224370.aspx : Connecting to Console session on a Remote server. When you use Remote Desktop Connetion (Start-Programs-Accessories-Communications-Remote Desktop Connection) to remote into an XP machine you get connected to the console session. I could not find a way to connect to the console session of a Win2K3 server using the Remote Desktop Connection UI Options button. The trick is to use the command line with the /console argument. *mstsc /v:servername /console* **Hope that helps, David Schmidt Lillis, Dara wrote: I run my Watir tests on remote pc's. I would like to manage the remote pc's using Remote Desktop, but encounter the following problem: When running tests that click on Modal Dialogs, tests that run fine (i.e. click successfully on modal dialogs) on my local pc and when managing the remote pc via netmeeting, hang forever when using Remote Destkop, at the point where the modal dialog appears. Anyone else had this problem? Anyone got a solution? Thanks, -Dara ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Setting Textbox throws unknown
As stated in the bug, this problem was caused by some performance improvement patches I submitted a while back. I don't normally use Regexp matches in my :id or :name elements so I didn't see this problem in my working code. There are actually two different problems in place here. First of all, IE doesn't understand regular expressions, so I've added code to make sure we only pass strings into getElementById() and getElementsByName(). That will stop the crashes caused by the regular expressions. The other problem is the one that causes the test case failure listed in WTR-77. That is caused by the fact that IE's getElementById() not only matches on :id, it will also matches on the first matching :name. I now double check the element returned by getElementById() to make sure that it really HAS a matching :id, else we fall back to the slow method. Lastly, not every element supports the fast get calls, but we can't use #respond_to? because these are OLE methods, not Ruby methods. Thus, the fast code is wrapped in a begin/rescue block so any element not supporting the get method will drop down to the slower code. All core tests now pass, including some new tests using regular expressions in :id and :name searches. David Schmidt Charley Baker wrote: Actually I can tell you why this is happening, it's related to the issue I was looking at yesterday, ie.element(:id, 'foo') actually searches by Name: http://jira.openqa.org/browse/WTR-77 Both are failing in the locate_input_element method. In the case of the Jira issue mentioned above getElementById() isn't working as it should be. In the case of regular expressions, it's simply sending the regular expression into getElementById or getElementsByName, straight ole_methods which causes problems for ie. We don't currently seem to have any regex searches on the input elements I've been looking at which is why they don't show up, regexs do work for non input elements which uses a different locator. Once we figure out how to handle this I'll add more unit tests. This is also related to the other issue you mentioned: WIN32OLERuntimeError: Unknown property or method `scrollIntoView' HRESULT error code:0x80010004 The caller is dispatching an asynchronous call and cannot make an outgoing call on behalf of this call. Somehow after the call gets screwed up there seems to be a hung connection to ie or something so that further calls to connect to other elements can cause this error. I've gotten it as well. As a temporary hack you can open watir.rb, go to the locate_input_element method, delete the whole begin/rescue/end block at the beginning and replace it with elements = ole_inner_elements -Charley ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Solution for accessing showModal Dialogs yet?
James, Try your tests with the latest 1.5 revision (1079). I've made some changes in the way click_no_wait works and one of them was to attach to the IE window using the window handle (HWND) instead of by title, which can sometimes find the wrong window. I'm running multiple web scraping sessions on one Windows box with many modal dialogs and I'm not having any problems with simultaneous modal dialogs because I have click_no_wait attach by HWND instead of by window title. David Schmidt Bret Pettichord wrote: James wrote: I should note, this script will work just fine, if it happens that two dialogs are not attempted to be opened simultaneously. Once this happens, the process hangs. If the opening and closing of modal dialogs occurs sequentially, no problem. but simultaneously won't work for me. Have you had success testing this sort of thing? Upon reflection on the methods we use to open modal dialogs, i can see how they could get confused and not work correctly. Please open a bug report in Jira for this. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] RegEx 151.1054
Watir 1.5.1.1079 should fix this problem. A patch of mine improperly allowed a Regexp to be passed to DOM's getElementById() call. David Adrian Lewis wrote: I think we got a problem with RegEx watir 151.1054 this'll work fine def password_field;$ie.text_field(:name, 'password');end this def password_field;$ie.text_field(:name, /password/);end rurturned on error of test failed: \nOLE error code:0 in Unknown\n No Description\n HRESULT error code:0x80010108\n The object invoked has disconnected from its clients. [c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1054/./watir.rb:3863:in `method_missing', c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1054 /./watir.rb:3863:in `doKeyPress', Why am I using RegEx? Cos in different environments my objects may have different prefixes or suffixes Cheers aidy ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Determining if control is hidden
I had this same problem, and the problem is deeper than it seems. I had an element and I had to determine if it was visible or not, but sometimes the element was NOT visible, even when it didn't have display: none or visibility: hidden. Turns out a parent DIV a few levels up *was* hidden, and all it's children were thus hidden. I've added a #visible? method to the modal_dialog branch which iterates up to the top of the DOM tree checking to make sure every parent element is visible. Note that this is a relatively SLOW call because the only way to ensure an element is visible is to make sure every parent is visible. If you place the following code in a file and require it you should be able to do an element.visible? call. class 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 element tree checking every element to make sure it's # visible. def visible? # 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 = object.parentElement end true end end David Schmidt [EMAIL PROTECTED] wrote: Is there an easy way to determine if a control (a checkbox in my case) is hidden? I have a checkbox that exists in a TD that (through several wrapped divs) ends up being hidden sometimes. Is there an easy way to determine this? I’ve tried: if $ie.hidden(:id, control id”) and if $ie.hidden(:name, control name”) And neither seems to work. 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] Subject:,Re: launch broswer as another user ?
We've also had a need to start up multiple instances of IE, each in their own process. (This allows us to run multiple scraping sessions to the same site and not have the session cookies over-ride each other, as long as the cookies don't have an expiration date which writes them to the file system.) Try this function in your app to start up each IE in it's own process: # This function starts each window as a unique IE process. # This allows the session cookies set for each IE scrape and # not overwrite session cookies set in other scraper sessions. def start_ie tf = Tempfile.new(scraper) basename = tf.path.sub(/^.*[\/\\]([^\/\\]*$)/, '\1') # get base filename html = sprintf(htmlheadtitle%s/title/head/html, basename) tf.puts(html) tf.close system(start iexplore #{tf.path}) ie = nil Watir::until_with_timeout(5) do begin ie = Watir::IE.attach(:url, /#{basename}/) rescue Watir::Exception::NoMatchingWindowFoundException false end end return ie end This does bring up a problem that we've had, however. If you try to start each IE as a different user then this method doesn't work, and click_no_wait doesn't work either. Apparently a process spawned from that IE running as a different user doesn't have the same permissions as a process running under as the logged in user. The call to find a window using Windows Shell.Application cannot see *any* IE windows if the spawning process is running as a different user. In addition, the logged in user cannot see any IE window created by another user. We haven't come up with a solution for this problem as it appears to be a problem in User32.dll used by Shell.Application. David Bret Pettichord wrote: Lonny Eachus wrote: Wow. Seems like an awful lot of work. Why not just use shell to start IE as any user you want using the Windows RunAs command, then attach to the window? Two short lines of code. In my case i needed to start up several browsers concurrently and in this scenario, the only way to attach to them reliably and cleanly is to know the process id of each browser. I stole most of the code from Alex Verk, so it wasn't really a lot of coding on my part. If you know of an easier way (Two short lines of code) to help Marco, i'm sure he and others would appreciate seeing it. 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] More details on cells not found by text
Mike, That test works fine under 1.5.1.1079 so it may be a problem in 1.4.1 that's been fixed since. If you need to remain with 1.4.1 then perhaps you can try an alternate method to get to that cell? I don't have 1.4.1 loaded, but try ie.table(:index, 1)[1][1].exists? and see if that works in 1.4.1. (Find table with index of 1, then find row 1, column 1.) David Mike Townley wrote: Using the following HTML: html head title celltest /title /head body table trtdtest/td/tr /table /body /html I attach to the window and run ie.cell(:text, “test”).exists? and irb returns false. ie.show_all_objects returns ‘nil’ ie.show_tables returns: “Found 1 tables 1 id = rows=1 columns =1 =nil” I’m currently running ruby 1.8.2 and watir 1.4.1, which the test was developed in. Thank you, Mike Townley ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Determining if control is hidden
Done: http://wiki.openqa.org/pages/viewpage.action?pageId=1119 The wiki editing isn't exactly obvious, and it kept complaining about the page title I used. Feel free to pretty it up if you like, but there's an example of extending Watir up there now. David Charley Baker wrote: Hi David, Can you post this to the user contributions wiki page? http://wiki.openqa.org/display/WTR/Contributions This is a good example of how to inject additional functionality into Watir. -Charley ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Click on the Tab
You can use the cell text contents to find the cell to click: table = ie.table(:index, 1)# Find the tab table using some method tab_cell = table.cell(:text, 'Parties') tab_cell.click If you know that this cell is the ONLY one with that text then you can just look for it anywhere on the page with: ie.cell(:text, 'Parties').click You can also regular expressions in the search: ie.cell(:text, /Par/).click David Schmidt [EMAIL PROTECTED] Chintakrindi Meghanath wrote: Hi I am trying to click a Tab in my application . I tried with various combinations, but couldnt succeed. Here is the source code can anyone help me ? I have to click on the Parties tab. div id='Zeroth_HdrTabId' style='position:absolute; left:0px; top:12px; width:595px; height:300px; z-index:1;align=left;visibility:hidden;' table width='595' cellspacing='0' cellpadding='0' border=0 align='center' trtd width='10'img name='a' src='/tc/img/en/a.gif' width='10' height='20' border='0'//td td width='81' background='/tc/img/en/on_tab.gif' class='blktext1' align='center' valign='bottom'Orderbrimg name='a' src='a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('1','11','DefaultActionTab',''); style='cursor:hand'*Parties*brimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('2','11','DefaultActionTab',''); style='cursor:hand'Transportationbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('4','11','DefaultActionTab',''); style='cursor:hand'Compliancebrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('5','11','FifthChild_ListTab|FifthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'Holdsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('6','11','SixthChild_ListTab|SixthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'Line Itemsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('7','11','SeventhChild_ListTab|SeventhChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'LineHoldsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='22'img src='/tc/img/en/aro_right.gif' width='15' height='20' border='0' onClick=displayTab('8','11','EighthChild_ListTab|EighthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'/td /tr /table Thanks Meghanath ___ 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] Click on the Tab
OK, that may be a feature of the 1.5 development thread, which I'm running here. Did you try it with the quoted version? ie.cell(:text, 'Parties').click I've found the 1.5 versions to be very stable and worth running, BTW. David Chintakrindi Meghanath wrote: Hi I tried with ie.cell(:text, /Par/).click but its not working. Thanks Meghanath -Original Message- From: David Schmidt [mailto:[EMAIL PROTECTED] Sent: Monday, July 31, 2006 2:33 PM To: wtr-general@rubyforge.org Cc: Chintakrindi Meghanath Subject: Re: [Wtr-general] Click on the Tab You can use the cell text contents to find the cell to click: table = ie.table(:index, 1)# Find the tab table using some method tab_cell = table.cell(:text, 'Parties') tab_cell.click If you know that this cell is the ONLY one with that text then you can just look for it anywhere on the page with: ie.cell(:text, 'Parties').click You can also regular expressions in the search: ie.cell(:text, /Par/).click David Schmidt [EMAIL PROTECTED] Chintakrindi Meghanath wrote: Hi I am trying to click a Tab in my application . I tried with various combinations, but couldnt succeed. Here is the source code can anyone help me ? I have to click on the Parties tab. div id='Zeroth_HdrTabId' style='position:absolute; left:0px; top:12px; width:595px; height:300px; z-index:1;align=left;visibility:hidden;' table width='595' cellspacing='0' cellpadding='0' border=0 align='center' trtd width='10'img name='a' src='/tc/img/en/a.gif' width='10' height='20' border='0'//td td width='81' background='/tc/img/en/on_tab.gif' class='blktext1' align='center' valign='bottom'Orderbrimg name='a' src='a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('1','11','DefaultActionTab',''); style='cursor:hand'*Parties*brimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('2','11','DefaultActionTab',''); style='cursor:hand'Transportationbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('4','11','DefaultActionTab',''); style='cursor:hand'Compliancebrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('5','11','FifthChild_ListTab|FifthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'Holdsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('6','11','SixthChild_ListTab|SixthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'Line Itemsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='81' background='/tc/img/en/tab_on3.gif' class='blktext1' align='center' valign='bottom' onClick=displayTab('7','11','SeventhChild_ListTab|SeventhChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'LineHoldsbrimg name='a' src='tc/img/a.gif' width='1' height='3' border='0'//td td width='22'img src='/tc/img/en/aro_right.gif' width='15' height='20' border='0' onClick=displayTab('8','11','EighthChild_ListTab|EighthChild_ListDvv|ListTab|ListDvv',''); style='cursor:hand'/td /tr /table Thanks Meghanath ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] DL::DLError too many callbacks defined from winClicker.rb (with fix)
While running a web scraping application under Mongrel we started getting a DL::DLError too many callbacks defined exception from winClicker.rb (which we're using to pull the static text from Javascript popups. I finally tracked this down to two problems in winClicker.rb where DL Callback blocks are defined. The first problem is that some of the callback blocks do a return from within the callback. This return doesn't just return from the callback, it returns from the winClicker function, bypassing the normal termination of the Windows EnumWindows or EnumChildWindows call. I've fixed this by properly setting the callback return code (bContinueEnum) so that the Windows call is properly terminated. In cases where the callback was trying to return a value from the callback I simply set a Ruby variable that is initialized outside the callback. However, this didn't solve the DL::DLError problem. Turns out that the DL library keeps it's own callback table (set in the DL.callback call). After digging through the DL C source code in dl.c I noticed that there is a DL.remove_callback call which is used to remove the callback from the DL table. I've added that call to all of the winClicker.rb methods which use DL.callback and my testing confirms that I'm no longer having a problem with that exception. I've checked this fix into the 1.5 development trunk as revision 1070. David Schmidt [EMAIL PROTECTED] ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Running Watir under Wine/CrossOver Office?
I've seen comments here and there on the net about folks running Watir under Wine or CrossOver Office. I've been trying both and have been having some problems. I've installed the latest Ruby one-click-installer and added c:\ruby\bin to the Wine path, and confirmed that path: $ wine ruby -e puts \#{ENV[\'PATH\']}\ C:\Windows;C:\Windows\System;C:\ruby\bin While Wine can find C:\ruby\bin\ruby.exe using that path, Ruby isn't able to locate commands using the same path, like IRB or GEM. I was able to get gem to work by using the full path to the gem command (wine ruby 'C:\ruby\bin\gem' list)and was able to get into IRB using wcmd. Has anyone else been running Watir under Wine that could give me some pointers on how to get Ruby and Watir configured correctly to run under Wine or CrossOver Office? David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Interesting link problem
I have a table that dynamically has an "n" number of entries as links. The table can sort by the last entry made in the table. I want to be able to click on the last entry or the last link that appears on the table. The problem is that I don't have attribute values to able to identify the link I want. I can't access the link by the inner text value because the text is also dyanmic. I will not know the name of the link until I access the page. The name changes as the table grows. So I'm not sure how to click on the link I want.Below is some of the html code and a list of the attributes from the sample. As you can see I don't have much that I can search by. Does anybody have any idea how I can click on the first link?a href=""AUTOTEST8142855/a/td tdJoe Player/td tdautouser9/td td[EMAIL PROTECTED]/td td0.00/td tdSterling/td td2006-06-23 01:00:33.0/td tdActive/td td1966-09-02/td td1/td/tr tr class="even" td a href=""AUTOTEST9229432/a/td tdJoe Player/td tdautouser9/td td[EMAIL PROTECTED]/td td0.00/td tdSterling/td td2006-06-23 00:51:27.0/td tdActive/td td1966-09-02/td td1/td/tr tr class="odd" td a href=""AUTOTEST8570615/a/td tdJoe Player/td tdautouser9/td td[EMAIL PROTECTED]/td td0.00/td tdSterling/td td2006-06-23 00:45:51.0/td tdActive/td td1966-09-02/td td1/td/tr tr class="even" td a href=""AUTOTEST6130026/a/td tdJoe Player/td tdautouser9/td td[EMAIL PROTECTED]/td td0.00/td tdSterling/td td2006-06-23 00:37:37.0/td tdActive/td td1966-09-02/td td1/td/tr tr class="odd" td --- http://admin-cqa-wpt-sat02.corp.wagerworks.com/WagerWareAdminwpt/accounts/browseAccount.do?playerCode=2606 inner text: AUTOTEST8142855 type: link id: name: value: disabled: false href: http://admin-cqa-wpt-sat02.corp.wagerworks.com/WagerWareAdminwpt/accounts/browseAccount.do?playerCode=2605 inner text: AUTOTEST9229432 type: link id: name: value: disabled: false href: http://admin-cqa-wpt-sat02.corp.wagerworks.com/WagerWareAdminwpt/accounts/browseAccount.do?playerCode=2603 inner text: AUTOTEST8570615 type: link id: name: value: disabled: false href: http://admin-cqa-wpt-sat02.corp.wagerworks.com/WagerWareAdminwpt/accounts/browseAccount.do?playerCode=2602 inner text: AUTOTEST6130026 type: link id: name: value: disabled: false ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Issue with gem 1.5.11037
Zeljko, Your problem is that that second require should be include Watir (with no quotes). When you did the second require you got messages for all the constants that were being re-defined. David Zeljko Filipin wrote: I do not know if this has any value: gem list *** LOCAL GEMS *** [...] watir (1.4.1) Automated testing tool for web applications. ruby -v ruby 1.8.4 (2005-12-24) [i386-mswin32] irb(main):001:0 require watir = false irb(main):002:0 require Watir== should be include Watir ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] very neat trick with Ruby system() (or any otherlanguage on Windows)
Bret, The current method is quite a bit different than the method that I wrote, and I'm not sure it will be as flexible. (For example, you can't attach to a Frame the way you can to an IE or Modal window.) My method is designed to completely re-create the exact method string to get back to the element to be clicked, and is working well for me right now, though there are some inconsistencies with table related elements (which is what got me looking at our current container/collection issue). I will probably give it another try once trunk settles down a bit and after we get the container/collection settled, but right now I'm getting ready to work on the container/collection issue first. Mark, you may want to look at the modal_dialog branch, which is what I'm using where I work, but right now it's missing a lot of the recent changes to trunk. It's at https://svn.openqa.org/svn/watir/branches/modal_dialog/watir and I'm doing lots of click_no_wait's from within frames. Feel free to contact me if you have questions about the code in that branch as it's pretty much my branch right now and it's probably a dead end until it's decided to port that code to the current trunk. David Bret Pettichord wrote: This is a known problem. (In other words, i knew about it, but it wasn't well documented.) http://jira.openqa.org/browse/WTR-6 The fix is for a Watir developer to write attach_command for Frames. David, this bug is currently assigned to you, but the surrounding code has changed since you signed up for this. Do you still want to do it? BTW, click_no_wait was recently enhanced so that it works in any context as long as you are not using frames. (If you see otherwise, please report it). Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Understanding WATIR
Actually, that *is* supported. However, if you look a sample HTML INPUT element from a page I'm scraping you'll find a clue why that particular example didn't work: INPUT id=SSNEntry_txtSpouseSSN style=\WIDTH: 95px\ value=999 name=SSNEntry:txtSpouseSSN For text_fields, the current text in the field is contained in the value attribute. Thus: ie.text_field( :value, 'xyz' ) Should work for you. David Manish Sapariya wrote: Thanks. This explains why I was getting all of my field getting flashed multiple times when I was traversing them by tables.each { cells.each { flash } } method. I have another query, hope you don't mind. We at work are using another tool QEngine, which basically makes available all the controls in flat space irrespective of whether the controls are in cells of nested table. So e.g. if i have a text box at nth level of table cell, watir does not make it available so that I can simply access it using ie.text_field (:text, 'xyz'). However QEngine makes this text box available like this. Where do watir lack in this regard? Regards, Manish ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Wait for control to exist
How about the easy way. Just alias your nice until_with_timeout to wait_until so both names work and just use that your first format with the block. That way the block can contain any code that returns a boolean, which will allow Andy's request for multiple element support to work like: wait_until(timeout) { ie.button(:id, 'btnOne').exists? and ie.span(:id, 'blah').exists? } with the timeout being optional and using a default_timeout like Bret suggests below. This can then support all *sorts* of things that folks wait for, including thing like the displayed spinners that I was waiting to appear and then disappear. David Bret Pettichord wrote: How about this: wait_until(ie.button(:value, OK).exists?, 10) The advantage of this form is that we could use any boolean expression. So you could wait until a control was disabled or whatever. I'm not 100% sure that i can code this, however. I know i can implement using a block. Thus: wait_until(10) {ie.button(:value, OK).exists?} This, of course, is the existing until_with_timeout method. Or: ie.button(:value, OK).wait_until_exists?(10) Which follows the normal Watir practice if putting the methods on the elements. Note that in all these examples the timeout would be optional and would default to a user-configurable value. Probably @@default_timeout. Also, if the timeout were exceeded, it would raise a TimeOutException. Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Problem finding a link URL with RegEx
Adrian Rutter wrote: Is it not possible to get the second link on a page? Something like: $ie.link(:text, 'New';:index, 2).click It is currently possible to access the second link on a page, but not with a filter. '$ie.links[2]' will give you the second link on the page, and you can open the page in IRB and do '$ie.show_links' to see which index to use for the link you want. David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Wait for control to exist
Our solution is better than that. Bret already has a method that I've been using and it's generic enough that you can wait for just about anything. He's stated that he'll just be renaming it to wait_for. On a web scraper I have there is an AJAX request that fires when one of the fields is changed. When this happens, a graphical spinner image appears to let you know it's making a request. The spinner is always there, but the DIV containing it gets changed from hidden to visible and back again. I'm able to wait for the style to change to visible and then wait for the style to change to hidden (even though the DIV *always* exists) like this (using the new wait_for() method name): # wait for Updating spinner to appear wait_for(5) do @ie.div(:id, 'pnlLoading').document.style.invoke('display') != 'none' @ie.div(:id, 'pnlLoading').document.style.invoke('visibility') != 'hidden' end # wait for Updating spinner to hide wait_for(30) do @ie.div(:id, 'pnlLoading').document.style.invoke('display') == 'none' || @ie.div(:id, 'pnlLoading').document.style.invoke('visibility') == 'hidden' end The wait_for method will just keep trying the supplied block until the block returns true or the timeout has passed (where it will throw an exception). David Andy Sipe wrote: I'm not sure just exist is enough for what I'm talking about. If I have a span that already exists in the document and I do something that causes an async request/update to the server then the span always exists so saying: span(:id, ...).wait_for_exists? may blow right through without pausing because the span is there. Maybe something like span(:id, ...).wait_for_change('text', 'blah') where 'text' is the attribute i'm waiting to change and 'blah' is the value I'm waiting for it to change to. So you could also do span(:id, ...).wait_for_change('exists?', true) -andy ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Wait for control to exist
Yup, my bad. I just typed the wrong name out of habit. New name will be wait_until. *SLAP* Ouch! OK, I've been punished. David Bret Pettichord wrote: On 6/13/06, *David Schmidt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: The wait_for method will just keep trying the supplied block until the block returns true or the timeout has passed (where it will throw an exception). We want it to be called wait_until -- correct? ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Table Row Bug -- How to fix?
Bret Pettichord wrote: inetdavid (6/8/2006 9:38:31 PM): Just found a problem with row_count with embedded tables. row_count counts *all* the rows, even rows in sub-tables, while show_tables shows the correct count because it uses a different method. I've first added a test to show the problem (using table_test on table(:index, 3) of table1.html) and I think I have the proper fix to just show/add rows from within the current table. This is the right way to do rows, but how do you want to make the change given that some folks may have coded using the incorrect value? This is http://jira.openqa.org/browse/WTR-26 My view is that we should do the right thing. This has been a common complaint and i don't think there is really much value in trying to retain the old, incorrect behavior. Is anyone depending on it? Comments? I agree, but wanted to check with you before fixing the problem and possibly breaking some existing script. However, I think it's more likely that Watir users have just learned to not trust row_count rather than depend on it's results where it may be in-accurate. To demonstrate the problem you can load one of the unittest html files that contains a nested table (unittests\html\table1.html). On that page table 4 is a sub-table of table 3, located in row 2, cell 1 of table 3. Table 3 has two rows and table 4 has 1 row, which is properly shown in a show_tables: irb(main):004:0 ie.show_tables Found 6 tables 1 id= rows=2 columns=2 2 id=t1 rows=5 columns=1 3 id=t2 rows=2 columns=2 == 4 id= rows=1 columns=2 == 5 id=body_test rows=5 columns=1 6 id=pic_table rows=1 columns=4 = nil The row_count for table 3 is not accurate though as it includes one row which is really inside table 4. (The row_count for all other tables is correct.) irb(main):005:0 ie.table(:index, 3).row_count = 3 irb(main):006:0 ie.table(:index, 4).row_count = 1 The to_a method has the same problem. You see the embedded table's values in multiple places, and the last array element is really an array from the embedded table. irb(main):007:0 ie.table(:index, 3).to_a = [[cell 1, cell2], [nest1nest2, nest1, nest2, Normal], [nest1, nest2]] irb(main):008:0 ie.table(:index, 4).to_a = [[nest1, nest2]] irb(main):009:0 The reason for the different counts became apparent when I looked at the DOM calls available that are being used. Using nested tables as an example, there is a rows call for tables, and that rows element has only two calls available: irb(main):017:0 ie.table(:index, 3).document.rows.ole_get_methods.sort = [_newEnum, length] This is the method used in show_tables, which is always accurate and gives you a count of how many rows are in the table. However, the method used within Watir to get all rows is getElementsByTagName, which returns *all* objects with a given tag below the current element. If you examine the DHTML Reference document for the TABLE Element (http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/table.asp) you can see that the rows method returns a collection of tr elements for the current table: irb(main):034:0 ie.table(:index, 3).document.rows.each do |row| irb(main):035:1* print \nNew row: irb(main):036:1 puts row.outerHTML irb(main):037:1 end New row: TRTDcell 1 TDcell2 /TD New row: TRTD TABLE TBODY TR TDnest1 TDnest2/TR/TBODY/TABLE TDNormal /TD = nil This works as it should. We can now re-code the Table#to_a method to properly iterate only over the proper rows. However, the getElementsByTagName method is called from many different places within Watir, and one of the places is Container#locate_tagged_element, which uses getElementsByTagName for many different tag types. The problem with this is that while the same method is used to get ALL tags of a given type, each DOM element has it's own *specfic* method to return the collection of specific child nodes (like rows for table rows, cells for table cells, etc). I think we'll have to look at each of those calls to getElementsByTagName to see if the call is appropriate, and re-code each if not. (The show methods can still use the getElementsByTagName because they can then show all sub-elements of the desired type, like the ie.show_tables method.) I think the first step will be to create unit tests to show each of the problems and then put in the code to fix each of the count problems till all the unit tests pass. Bret, do you want me to start on this? David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] BUG: New IE windows share session state with existingopen windows
There's another issue which may be affecting your test that is also NOT a Watir bug. Sessions are often set by having a server save a session ID cookie on the IE's PC. For IE, these cookies are saved in a per-user directory. If you run multiple IE's to the same site then the cookies can be overwritten, causing much confusion! IE1 browses to www.somesite.com and a session id is saved. IE2 browses to www.somesite.com and a DIFFERENT session id is saved to the same cookie IE1 browses to another page under www.somesite.com, returning the cookie WHICH IS NOW IE2's COOKIE! We had this problem running some web scrapers simultaneously to the same site from the same computer. We solved the problem by running each scraper under a different user so each scraper got it's own folder for cookies and they then stopped overwriting each other. David Michael Bolton wrote: This isn't a bug in Watir, so the BUG: title for your message isn't appropriate. There are lots of bugs here, but they ain't in Watir. Does your script include 'require watir.rb' and 'include Watir' at any point? When you try to attach using a string literal, it's unlikely to work for attaching to the window by title, unless it includes the entire title string exactly. A regular expression needs only a subset, so when you're trying to attach, do this: foo = IE.attach(:title, /Google/) However, you don't NEED to attach, so in this case, don't bother. There's no need for the call to WIN32OLE; there's no need to call system(). Watir takes care of all this stuff. You've set up an array presumably to hold three browser instances, but you're assigning all three instances to the same element in the array. I gather what you're trying to do is this: require 'watir.rb' include Watir ie_array = Array.new(3) ie_array.each do |element| element = IE.start('http://localhost:8080/kmdm8/signon.jsp') end Right? ---Michael B. ___ 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?
Tyler, I know this isn't supported right now. I did some investigation and I don't see a navigate function in the frame's OLE object (which is used by the base IE object in goto). I even tried to do a raw substitute in the IE document that contains the frameset, but was unable to find an element that IE would let me modify that would include the frame src string. There *may* be a way to substitute a frame source, but I've not been able to find a way yet. To find which methods work with different elements you can do element.methods.sort, or if the method is an OLE method being sent to IE you can do things like element.document.ole_methods to see what IE will let you do. Hope that helps, David Tyler Prete wrote: I am trying to get a frame on a page to load a specific page, i.e. $ie.frame(:name, 'name').goto(' http://specificsite.com' http://specificsite.com%27), but when I do this I get a NoMethodError. I know that show_all_objects works within a frame, as well as most of the interactive methods (text_field, button, click, etc), but is there anyway to know which ones will work and which ones won't without trying it? Also, is there another way to do what I am trying to do? Thanks, --Tyler ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] 1.5 modal dialog. Syntax of supported tags ?
Marco, Looking at your HTML below I think that the problem is that your button is located inside a frame, which is loaded via another URL. Because of that, the element would be in a different Watir container and wouldn't be found inside the top level container for that modal dialog. Assuming that the frame main has the button you want, you should be able to click on it by using: modal.frame('main').button(:text, 'Yes').click Let me know if that works for you. David Schmidt Neri, Marco wrote: Hi I'm running v1.5.1.1017. I need some help re modal dialog. I'm using this code to access a modal dialog: @ie.link(:text, Delete).click_no_wait modal = @ie.modal_dialog(:title, 'Confirmation') puts(modal.to_s) modal.button(:text, 'Yes').click In the console the puts shows #Watir::ModalDialog:0x27c0970. Based on this I assume it has found the dialog using the title because no error is thrown. I'm not 100% sure though. I had a look in the src for ModalDialog.rb but cannot see a method that I could use to to get a list of all elements in the dialog. The button click is not working the console shows the error: 1) Error: test802(TC_test802): Watir::Exception::UnknownObjectException: Unable to locate object, using text an d Yes c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1017/./watir.rb:2237:in `assert_e xists' c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1017/./watir.rb:2378:in `click' C:/visual studio projects/VictoriaPolice/AttendanceTests/bug802.rb:61:in `te st802' I have the same issue if I use value and insert a value=Yes into the src for the dialog. I also tried using :index The src for the dialog: html head TITLEConfirmation/TITLE meta name=GENERATOR content=Microsoft Visual Studio.NET 7.0 meta content=http://schemas.microsoft.com/intellisense/ie5; name=vs_targetSchema /head frameset border=0 rows=0,100% frameSpacing=0 frameBorder=0 frame name=header src= scrolling=no noresize frame name=main src=ConfirmDelete.aspx /frameset /html The src for confirmdelete.aspx: div id=ConfirmDelete img src=../Images/ICO_EXCLAMATION.gif plabel id=MessageLabel runat=server/label/p div id=confirmbuttons button type=submit runat=server onclick=javascript:OnYesClick();Yes/button button type=submit runat=server onclick=javascript:OnNoClick();No/button /div /div Is the issue that the buttons are defined using submit instead of input type=button value=Close - does this means that the modal dialog support in 1.5 is restricted only to dialogs implemented similar to the example in unit test. ? Any suggestions? thanks Marco ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Need help reading a file
Jassi, I'm not sure what commands were added in the different versions, and without the actual error you're getting and without the actual HTML it's hard to be certain what's wrong. In particular, I'd like to see the HTML for the radio buttons that you're trying to set. The form of the radio command I gave you assumes that the id is the value of the radio button. If that value is the id in the radio button you'd use a different form like test_site2.radio(:id, id).set (set the radio button with the id equal to the value in your id variable). What I'd do in this situation is to run these commands in IRB and see what output I get after each command. For example, after the cell command you should see a valid id. You could also enter test_site2.cell(:text, Arbitration).html to see the entire html for the cell. Once you're sure that you have the right value in your id variable then you need to make sure that you are able to find the correct radio button with the value equal to the id variable. Working in IRB lets you try different things very quickly to find the exact command you need. If you could be more specific about where things are failing and send along the HTML for the radio buttons then we'll have a better chance to help. I'm going to be away from the computer for a few days, but if you're still having problems next week I'll continue to try and help. David Jassi Akkal wrote: David, Do I have to have 1.5 version of the watir because I am using 1.4 version. Also here is the updated code and still it is not working test_site2 = Watir::IE.attach(:url, 'http://gcmapp2.qa.kryptiq.com:8080/guardian/servlet/guardian/template/ItemChooser.vm?chooserType=CUSTOM_CONTRACT_DOCSET') id =test_site2.cell(:text, Arbitration).id test_site2.radio(:name, selectionids, id).set test_site2.image(:id,btnChooseSelected).click Appreciate that. Thanks Jassi Akkal --- David Schmidt [EMAIL PROTECTED] wrote: Jassi, One thing I see is that you didn't include the Watir object for the radio button. Also, you placed quotation marks around the id in the radio setting line. You don't want an id that is equal to id, you want what's in the variable id so there would be no quotation marks around the variable name. The line to set the radio button should read: test_site2.radio(:name, 'selectionids', id).set David Schmidt [EMAIL PROTECTED] Jassi Akkal wrote: Bret, Thanks for the help. But it is not working for me and here is my code test_site2 = Watir::IE.attach(:url, 'http://gcmapp2.qa.kryptiq.com:8080/guardian/servlet/guardian/template/ItemChooser.vm?chooserType=CUSTOM_CONTRACT_DOCSET') id =test_site2.cell(:text, Arbitration).id radio(:name, selectionids, id).set test_site2.image(:id,btnChooseSelected).click Any help will be appreciated. Thanks Jassi Akkal ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] `method_missing': document (WIN32OLERuntimeError)
Bret, This is the same problem that was occurring in wait(). The COM object document method is called when the document method isn't available. I've seen this if a page or frame immediately kicks off a new page load before all the wait checks are complete or perhaps if the check is called before the page/frame is completely ready. Fix would similar to the one in wait where you make sure a document is available: (from IE#wait) until suppress_ole_error [EMAIL PROTECTED] do sleep 0.02; s.spin end David Bret Pettichord wrote: This looks like a new problem, although related to problems we've seen before (and mostly fixed). I'm puzzled how it could happen -- but i'm not sure what information to ask for. Bret On 5/24/06, *Manish Sapariya* [EMAIL PROTECTED] mailto:[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 this again with the same script. Please let me know if HTML page or code will help isolate this problem. Thanks and Regards, Manish c:/program files/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:0x80020009 Exception occurred.from c:/program files/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:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:205 from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir- 1.5.0.1005/./watir.rb:203:in `upto' from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:203 from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:201:in `call' from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.1005/./watir.rb:1558:in `run_error_checks' from c:/program files/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 list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] `method_missing': document (WIN32OLERuntimeError)
Bret Pettichord wrote: On 5/24/06, *David Schmidt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: This is the same problem that was occurring in wait(). The COM object document method is called when the document method isn't available. I've seen this if a page or frame immediately kicks off a new page load before all the wait checks are complete or perhaps if the check is called before the page/frame is completely ready. The reason for my concern is that this error is in check_for_http_error. This method isn't called until after all the wait checks are complete and Watir thinks that the page is already fully loaded. So that means that there is a bug in the core wait code. Not necessarily. I have pages in my web scraper that load and then immediately run code to load a *different* page, just like a redirect. Yes, this is ugly and not great web design, but it is being done. If Watir is still checking return codes on the first page while IE starts the process to load the NEXT page then the COM document method may not be valid when we're still trying to check the results of the first page load. Fix would similar to the one in wait where you make sure a document is available: (from IE#wait) until suppress_ole_error [EMAIL PROTECTED] do sleep 0.02; s.spin end The problem with this is that it would only suppress the symptom without addressing the cause, and the same problem could just as easily arise somewhere else. Do we wrap guards around every call in Watir to @ ie.document and every other COM call we ever make? That would only make errors nearly impossible to diagnose. Do we need to add more wait checks to the core wait logic? Why haven't we seen the problem before? I suspect that this isn't a common occurrence, which is why it hasn't shown up frequently in the past. In addition, wasn't the code to check the status of loaded frames added only recently? That could cause this to show up more frequently if the base page or a previous frame triggers a new page load. I don't see what we can do but abort the checks and perhaps start checking all pages (base IE and frames) again, because we can't continue checking old pages if they're no longer there. This is why I recommended placing the frames.each inside the begin/rescue block for WIN32OLE errors in IE#wait, because we may have a different number of frames if a new page load is triggered while Watir is in IE#wait. Since calls to check_for_http_error would normally only occur when we're expecting a new page then I think we should just let the WIN32OLE exception filter to up the method calling check_for_http_error and then make sure those spots handle the exception as appropriate. In IE#wait I would propose we assume that we are seeing a new page load and re-start the entire wait, re-checking the base IE document and all the sub-frames. This is the reason for my puzzlement. If there is really a flaw in the wait logic i suspect we'll be seeing problems elsewhere. Is this a new problem cause by the recent rearrangement of the wait code that i thought would have no impact? Is this a problem that was previously masked by other bugs and is only now showing up because we've added guards to other places (where they reasonably belong)? Have i missed something serious in my analysis of this area? We don't really have unit tests for this code, and it has always made me the most nervous. These problems all show up as race conditions. And yet the ability of Watir to have reliable synchronization has been absolutely key to its success. So we have to get this right. I'm not sure there is a way to determine for sure if the page has been reloaded or not. The title and url may not change, and the COM object doesn't change either. We can restart the error checks and make sure any NEW page has completed successfully, but we just may not be able to detect a new page load while we're checking the status of the first page. Bret BTW, since there can be framesets within an existing frame the code in IE#wait should really check each found frame to see if there are additional frames being loaded from within that frame. I have some sites where I see 3 levels of frames (@ie.frame(x,x).frame(x,x).frame(x,x).element). David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] [question] Accesing images?
Rodrigo, Examining the HTML I see that the image with id of img2 isn't even in the div with id DIVImageFile_2. In addition, the img2 image doesn't have any events associated with it, so clicking that image won't do anything. I think the link you wish to follow is the link following img2: a href=javascript:quitar(2) id=quitar2 style=visibility:hiddenQuitar/a Try: $browser_popup.frame('responseFrame').link(:id, 'quitar2').click to click the link following the img2 image. David Schmidt [EMAIL PROTECTED] Rodrigo Julian Martin wrote: Thanks for the answer Lonny, and sorry for that untidy HTML! I’ll download TidyUI… I’m trying to click the image with this: $browser_popup.frame(:name,responseFrame).div(:id, DIVImageFile_2).image(:id, img2).click And the output shows: c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:856:in `getImage': undefined local variable or method `document' for #Watir::Div:0x558 (NameError) from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2690:in `initialize' from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:608:in `new' from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:608:in `image' from subir_fotos:27 Or directly with this sentence… $browser_popup.image(:id,img2).click That sentence doesn’t throw any error, but it doesn’t click the image as the popup that should appear doesn’t…. Any help would be really appreciated.. Thanks in Advance! Rodrigo Julian Martin ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] frame error in waitreadyState
Manish, It's a bit hard to tell exactly what's occurring without seeing the HTML or the Watir script involved, but I've seen this type of error before. It's a COM error trying to send a command to IE, and from the trace I'd guess it was a wait command. Since it was right after a click I'm guessing that perhaps the wait executed at a time when the object state wasn't stable. Could you give us an idea what you were clicking? Was it in a frame or in a popup or just a normal web page? I'm also not sure what you mean by defaulting function below. Could you explain in more detail what changes you make betwen this working and not working? David Manish Sapariya wrote: I get following error when I run my script. However when I run script with the defaulting function alone, it works fine. Any ideas? Has anyone run into this kind of issue. Please let me know if you need more details to help. --- W, [19-May-2005 16:15:24#3268] WARN -- : frame error in waitreadyState OLE error code:0 in Unknown No Description HRESULT error code:0x80070005 Access is denied. c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:1518:in `method_missing' c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:1518:in `wait' c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:1517:in `upto' c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:1517:in `wait' c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:293:in `wait' c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:2302:in `click' iManager.rb:151:in `CreateImageSearch' iManager.rb:346:in `CreateAndScheduleImageSearch' iManager.rb:343:in `each' iManager.rb:343:in `CreateAndScheduleImageSearch' iManager.rb:750 c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:2156:in `assert_exists': Unable to locate object, using text and Images (Watir::Exception::UnknownObjectException) from c:/program files/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.980/./watir.rb:2297:in `click' from iManager.rb:152:in `CreateImageSearch' from iManager.rb:346:in `CreateAndScheduleImageSearch' from iManager.rb:343:in `each' from iManager.rb:343:in `CreateAndScheduleImageSearch' from iManager.rb:750 Exit code: 1 Thanks and Regards, Manish ___ 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] WaitForObject
Adrian, I have this on my list of things to add to Watir once I get the modal dialog support and tests finished, but I have a method which I include in my Watir scripts to wait for specific objects. You can copy it from http://inetdavid.backpackit.com/pub/585884 and paste it into your own Watir script and modify for your own use. (The current script calls our own log method so that will probably need to be changed.) Hope that helps. David Schmidt [EMAIL PROTECTED] Adrian Rutter wrote: Hi, I was wondering if Watir had a method that will make the script wait until a specific object appeared? Also, is there a method to wait until a page has successfully loaded? Thanks 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 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] need help with radio button
Jassi, I'm guessing that there is a close quote after the 'name=selectionids' below? If so, then this should work for you: ie.radio(:name, 'selectionids', '8bf19f48-9462-4285-90ef-241f4fd5f7f7').click (or .set) If the HTML isn't well formed and there *is* a missing quote then perhaps you can click on it by just using the value as in: ie.radio(:value, '8bf19f48-9462-4285-90ef-241f4fd5f7f7').click (or .set) If there *is* a closing quote then either of those should work. David Schmidt [EMAIL PROTECTED] Jassi Akkal wrote: Hi, I am very new to the watir and i have been struggling with not being able to select the radio button. My HTML code is listed below input type=radio name=selectionids value='8bf19f48-9462-4285-90ef-241f4fd5f7f7' I used ie.radio(:name, selectionids,'8bf19f48-9462-4285-90ef-241f4fd5f7f7').set, but it is not working for me. I will appreciate any help. Thanks Jassi Akkal jassi akkal [EMAIL PROTECTED] __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ 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] Tricky select list
George, You can do something like ie.select_list(:index, 1).select('All') to select the All option. I'm assuming here that this is the first select_list in the HTML since this is just a partial. If the select list had an id or name you could do something like ie.select_list(:id, 'select id').select('All') David George Hawthorne wrote: Hi, Could anyone suggest the correct way to select option 0 from the list shown in the following HTML example? By default option 1 is selected and I can't figure out how to get WATIR to change the selection. TIA. input type=hidden name=people$hSelectId id=people_hSelectId / div id=people_divXtable class=genTable style=width:480px; div id=divXTableD style='width:480px' div class='mainGenDiv' style='overflow:hidden;' table tr class='header' td div style='width:62px;' a href=javascript:OnSort('D',0);First Name/aimg src='img/filterup_off.gif'/img src='img/filterdown_on.gif'/br / select onchange=OnFilter('D',0,this); style='width:54px;' option value=0All/option option selected='selected' value=1Assigned/option option value=2A/option option value=3B/option option value=4C/option option value=5D/option ... /select /div /td George ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Thoughts on modal dialog implementation in development Watir
I got the SVN URL and checked out watir/trunk into RadRails, but I see that the repository is set up with what looks like sub-projects. I tried to grab just the watir project directory (watir/trunk/watir) using SVN, but got the following error: svn: PROPFIND request failed on '/svn/watir/!svn/bc/982/trunk/watir' svn: Processing PROPFIND request response failed: XML document structures must start and end within the same entity. (/svn/watir/!svn/bc/982/trunk/watir) Does anyone have a good setup for using RadRails for Watir, using the Subversion from within RadRails? For now I'll load up an external Subversion client and see if I can import the projects from a local directory checked out using Subversion. David Bret Pettichord wrote: David, Zelko sent you the SVN url. Please send a patch (or attach it to a Jira task). We'll need to make sure we have unit tests for your code before it is committed. Appreciate the help! Bret ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Thoughts on modal dialog implementation in development Watir
Bret Pettichord wrote: On 5/11/06, *David Schmidt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Bret and all, I was overjoyed to find the Watir::IE#attach_modal() method in the current development tree and quickly started experimenting in IRB to see how best to use it. I quickly found that the last method call in attach_modal(), ModalDialog.new(), hasn't yet been implemented (at least in the tarball I got). Please look again. Here is the code in watir.rb. I'm not sure where you got that tarball. CVS? Rubyforge? You need to find our current code. Dev builds and source on OpenQA.org. Well, I can't even *find* where I got it now even though I got it Tuesday, but it was Revision 1.282, version 1.4. I just grabbed the 1.5.0.980 gem but would still like a repository URL if there's a public one. Do you have a CVS (or better yet, Subersion) URL that I can get the latest version from? Then I can generate a patch against that (or possibly get commit rights) and have you check it out. I think I have all the pieces and we just need to integrate them and flesh them out with all the how/what options. class ModalPage IE def initialize(document, parent) @ie = parent.ie http://parent.ie # Bug should be transferred from parent @document = document set_fast_speed @url_list = [] @error_checkers = [] end def document return @document end def wait end end (If you look closely, you'll see my subtle implementation of ModalPage#wait.) Your masterful implementation of ModalPage#wait was exactly what was called for. Select now works fine and doesn't block. In addition, I saw that the only way to select a modal dialog was by :title. True I manually entered the Watir::IE#attach_modal() code into IRB and was able to get an htmldoc variable pointing to my modal dialog. From that I could get the html using htmldoc.documentElement.outerHTML() (WHOOHOO!). However, the modal dialog that I'm attaching to has a select_list and for our application (a scraper application, not a QA application) we need to be able to read the values from the select_list. Now, of course I could just take the HTML I now have and use a regular expression to get the data we need, but it sure would be nicer to use the functions in Watir, wouldn't it? OK, so I started to look at how to implement the WatirDialog class as called in the current Watir::IE#attach_modal method and I think I found out why this wasn't implemented yet. Watir::IE#attach_modal is able to find a Document object, but I don't see any way to get an Internet Explorer Object to place into the @ie instance variable. I also still have the problem that the current Watir::IE#attach_modal method only connects to the modal dialog by using the dialog's title. This can give us problems if multiple dialogs have the same title, as could easily happen if you are running multiple concurrent IE instances (as we are). See how we did this above. I added my implementation into the latest gem I found (1.5.0.980 from http://wiki.openqa.org/display/WTR/Development+Builds) and it's working for both :hwnd and :title: irb(main):001:0 require 'watir' = false irb(main):002:0 include Watir = Object irb(main):003:0 ie = IE.attach(:title, /SAM/) = #Watir::IE:0x2f9aa50 [...] irb(main):004:0 dialog = ie.modal_dialog = #Watir::ModalDialog:0x2f95c08 [...] irb(main):005:0 dialog = ie.modal_dialog(:hwnd) = #Watir::ModalDialog:0x2f924b8 [...] irb(main):006:0 dialog = ie.modal_dialog(:title, 'Determinant Select') = #Watir::ModalDialog:0x2f8ddd8 [...] irb(main):007:0 dialog.button(:id, 'btnCancel').click = nil irb(main):009:0 Watir::IE::VERSION = 1.5.0.980 I then though, since a given instance of IE can only have ONE modal dialog open, wouldn't it make more sense to find a modal dialog by using the current IE object? Yes, if you can do it. Frankly, i don't know how. I found the methodology in WET. Also you can have more than one modal, namely a modal can itself launch another modal. I know it sounds sick, but the app i'm testing actually does this. ACK! I just confirmed this by taking my dialog object above and doing: dialog.document.parentWindow.showModalDialog('URL') and it brought up a child modal which blocks the first one. That truly *is* sick. We can get to it by title, but to get to it by inheritance I'll have to save the hwnd_modal value of our first modal dialog into the container so it's available to the following modal_dialog() call. I've never found a way to get the HWND from an IE Document or Window object. It can be done though and would look like this: second_dialog = IE.attach(xxx, xxx).modal_dialog.modal_dialog How does that look to you? I've been digging
Re: [Wtr-general] frame.html fails in development version
I added a comment to that JIRA bug and can make a patch if necessary, though the fix is simply moving the html method from Watir::IE to the Container Module. David Schmidt Paul Carvalho wrote: This is a known problem in 1.5. The description is perhaps not clear enough to be found by a search, but it is in JIRA: http://jira.openqa.org/browse/WTR-13 Technically, there's nothing wrong with the google_maps.rb script... it just fails because the frame.html fails in the script. Paul. On 10/05/06, *David Schmidt* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I have some code which was using Frame#html which was inherited from Watir::IE in 1.4. In 1.5 this broke because Frame is no longer inherited from IE. I moved Watir::IE#html to the Container module and now it's working fine because both Watir::IE and Watir::Frame include Container. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Trouble closing JavaScript pop-up invoked from a frame in Watir 1.5.0.945
Bret, I've been using Watir for about 6 months now and I may have a fix for this problem that I just wrote today for 1.4.1 and re-wrote tonight after finding the newer development sources. I wrote a to_identifier() method which generates a string containing the full classes to find the current object to click. This can then be run in another thread to do the click_no_wait(). Because the application I'm working on doesn't always have a unique title I also modified the 1.4 attach_browser_window() function to also allow attaching to a running IE identified by :hwnd in addition to the normal :name or :title. This *guarantees* that you are clicking in the same window that your current Watir process is working with. Here's an IRB log of how it works after digging down to a button inside nested framesets: irb(main):001:0 require 'watir' = true irb(main):002:0 include Watir = Object irb(main):003:0 (added to_identifier method here) irb(main):022:0 my_ie = IE.attach(:title, /SAM/) irb(main):023:0 frame1 = my_ie.frame('Main') irb(main):024:0 frame2 = frame1.frame('workarea') irb(main):025:0 button = frame2.button(:id, 'btnCont') irb(main):026:0 button.to_identifier = IE.attach(:hwnd, 198076).frame(:name, 'Main').frame(:name, 'workarea').button(:id, 'btnCont') irb(main):027:0 This method should be able to be added to the Containers module so it should work fine with elements in nested frames like above. def to_identifier current_object = self array = [] # generate a string to identify the current object, suitable for passing to # an external process or thread for click_no_wait. while current_object and !current_object.instance_of?(Watir::IE) parent_object = current_object.instance_variable_get(@container) class_string = current_object.class.to_s.sub('Watir::', '').downcase how_string = current_object.instance_variable_get(@how).inspect what_string = current_object.instance_variable_get(@what) # Get object string (like Button(:id, 'button id') array #{class_string}(#{how_string}, \'#{what_string}\') current_object = parent_object end array IE.attach(:hwnd, #{current_object.ie.HWND}) array.reverse.join('.') end This is NOT a complete solution, as I didn't look at images yet, only the buttons and links. Here's the snippet I added to attach_browser_window() in the case statement to allow to attaching to an IE instance by :hwnd: when :hwnd # find window by HWND log hwnd is: #{aWin.HWND} ieTemp = aWin if (what == (aWin.HWND)) David Schmidt [EMAIL PROTECTED] -- Yes, this problem will need to be fixed before we release Watir 1.5. Bret On 4/28/06, Rosalind de Vera [EMAIL PROTECTED] wrote: Hello, I have a link in a frame that brings up a _javascript_ popup-up. When I try to use click_no_wait, I get the following error: irb(main):015:0 ie.frame(topFrame).link(:text, Reset Settings).click_no_wait NoMethodError: undefined method `eval_in_spawned_process' for #Watir::Frame:0x2d0bf30 from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.0.945/./watir.rb:2293:in `click_no_wait' from (irb):15 Will this be fixed at some point? I saw a posting on March 24 by lyoungz in the openqa.org forum asking about the same problem, but I didn't see a response. Thank you, Rosalind ___ 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] Running Multiple Instances of IE
The company I work for is running multiple screen scraping sessions and we ran into some of the same problems. The biggest problem was that the session cookies would get overwritten and the scrapes would get crossed. Our final solution was to run each scraper under a different user, which places their cache/cookie directories into different directories so that the session keys don't overwrite each other. I didn't set up that environment so I don't have the exact commands handy, but I know our other engineer found a way to spawn all the sessions from one login, using some 'run as' parameter to specify the user for each Watir process. Hope that helps, David Schmidt [EMAIL PROTECTED] John Fitisoff wrote: Help! I'm new to Watir, and am trying to get my company to use it, but am running into a problem. I'm trying to run multiple, independent windows without having them interfere with each other. I've tried a few different things: -ie, ie1, ie2 etc... (no globals) -Using winclicker to launch an existing HTML page and then attaching to it. -Looking at the concurrent_tests example. The reason that I'm doing this is I need to fit this in with what the build engineer is already doing. To make him happy, I need to deliver a suite of tests that can be run against different servers on the network, and at least some of the time these tests are going to be run simultaneously on a system that will host the test. In some cases, two different test suites would be running at the same time. I don't think I can use the concurrent example because these tests won't be run at exactly the same time and I also need to pass the test suite a base url for the server I'm testing against. No matter what I've tried, the instances end up interfering with each other and some of the tests fail with errors. Is there some way to work around this? I'm not the most technical person in the world but this is a really cool automation tool and I'd like to get it adopted here for UI testing. I'm not sure if I'll be able to do that if I can't figure out how to get past this. Please don't make me go back to HTML Unit. :-) Thanks John ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Undefined Method Error
$ie.link(:text, "Pay Model").click(); table = $ie.table(:index, 9) #table.flash sleep 1 table[1][5].image(:name, "updatetop").click assert($ie.contains_text($no_permission_msg)) ! $ie.link(:text, "Game Library").click(); table = $ie.table(:index, 9) sleep 1 table[1][3].image(:name, "updatetop").click assert($ie.contains_text($no_permission_msg)) $ie.link(:text, "Game Settings").click(); assert($ie.contains_text($no_autho_msg)); $ie.link(:text, "Game Menu Tabs").click(); table = $ie.table(:index, 9) sleep 1 table[1][3].image(:name, "updatetop").click assert($ie.contains_text($no_permission_msg)) $ie.link(:text, "Community Games").click(); #table = $ie.table(:index, 9) #sleep 1 #table[1][3].image(:name, "updatetop").click #assert($ie.contains_text($no_permission_msg)) $ie.link(:text, "Community User Migration").click(); # No update button available. Need to figure out how to assert false for no buttons $ie.link(:text, "Community User Upload").click(); # Need address attaching files #$ie.link(:text, "Community Management").click(); #$ie.text_field(:name, "newCommunity").set("Test") #table = $ie.table(:index, 10) #sleep 1 #table[1][3].image(:name, "form_top_singl_create").click #assert($ie.contains_text($no_permission_msg)) <f! ont size="1"> $ie.link(:text, "Jackpot List").click(); # Jackpot lists allowed - research test case $ie.link(:text, "Jackpot Details").click(); table = $ie.table(:index, 9) sleep 1! table[1][3].image(:name, "updatetop").click assert($ie.contains_text($no_permission_msg)) $ie.link(:text, "Jackpot Adjustments").click(); $ie.text_field(:name, "AdjustAmt").set("1000") $ie.text_field(:name, "ReasonText").set("This is a test") table = $ie.table(:index, 19) sleep 1 table[1][3].image(:name, "createbottom").click assert($ie.contains_text($no_permission_msg)) ! $ie.link(:text, "Settings").click(); end endAny ideas?Thanks David ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Another JavaScript Question
All,I've been trying desperately for over week to figure out how to click on _javascript_ button to no avail. I have tried just about everybody's suggestions. Mark Cain's solution posted last weeklooked very promising, but can't get it to work. Here is the code that contains the buttons (cancel update) Ineed to click on:table cellpadding="0" cellspacing="0" border="0" width="300" trtdimg src="/images/admin/form_top_left.gif"/tdtd background="/images/admin/form_top_tile.gif"img src="/images/admin/spacer.gif" width="10" height="48"/tdtda onClick="return validate_form('ADMINPayModelUpdate','enable')" ONMOUSEOVER="imgswap('enablealltop', 'form_top_enableall_over'); return false;" ONMOUSEOUT="imgswap('enablealltop', 'form_top_enableall_up'); return false;"img NAME="enablealltop" src="/images/admin/form_top_enableall_up.gif" value="Enable all" border="0"/aa onClick="return validate_form('ADMINPayModelUpdate','disable')" ONMOUSEOVER="imgswap('disablealltop', 'form_top_disableall_over'); return false;" ONMOUSEOUT="imgswap('disablealltop', 'form_top_disableall_up'); return false;"img border="0" NAME="disablealltop" src="/images/admin/form_top_disableall_up.gif" value="Disable all"/a/tdtd background="/images/admin/form_top_tile.gif"img src="/images/admin/spacer.gif" width="226" height="48"/tdtda href="_javascript_:document.ADMINPayModel.reset()" onClick="return validate_form('ADMINPayModelUpdate','cancel')" ONMOUSEOVER="imgswap('canceltop', 'form_top_cancel_over'); return false;" ONMOUSEOUT="imgswap('canceltop', 'form_top_cancel_up'); return false;"img NAME="canceltop" src="/images/admin/form_top_cancel_up.gif" border="0"/aa href="#" onClick="return validate_form('ADMINPayModelUpdate','update')" ONMOUSEOVER="imgswap('updatetop', 'form_top_update_over'); return false;" ONMOUSEOUT="imgswap('updatetop', 'form_top_update_up'); return false;"img NAME="updatetop" src="/images/admin/form_top_update_up.gif" value="Update" border="0"/a/tdtd background="/images/admin/form_top_tile.gif"img src="/images/admin/spacer.gif" width="6" height="48"/tdtdimg src="/images/admin/form_top_right.gif"/td /tr /tableThanks! David Do you Yahoo!? With a free 1 GB, there's more in store with Yahoo! Mail.___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Unable to run watir from IRB
I am trying to do the scripting 101 tutorial. I installed everything as directed. The server is running, ruby and watir is installed. In fact, I am able to run the unittest demo that came with watir. However, when i try to execute watir from irb I get the following error.irb (main):001:0 require 'watir' dError: No such file to load -- watir from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r ire__' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/loadpath_manager.rb:5:in `r ire' from (irb):1 (main):002:0 my first instinct is to think the path is not cor! rect. Any ideas? Yahoo! Shopping Find Great Deals on Holiday Gifts at Yahoo! Shopping ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general