[wtr-general] Re: 'matches' method for regexp gives error
I guess this will work: @mytestvalue = $ie.span(:id, 'db_data').text.match(/db_[0-9]*/).to_s On Dec 16, 12:07 pm, Paul Rogers paul.rog...@shaw.ca wrote: what does $ie.span(:id, 'db_data').text return - it might be a problem with your regular expression. What are you expecting @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\]*/) to return ( ie what are you hoping to get back ). he to_s on the end iis unlikely to be needed Paul On Tue, Dec 16, 2008 at 11:02 AM, maven999 maven...@gmail.com wrote: Hi Paul, Thanks for your quick reply. It doesn't work. And neither does it work when I convert the result into string: @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\] */) .to_s I think the problem is the datastructure that the $ie.span(:id, 'db_data') returns. If it is an array, maybe I should be parsing it a different way? On Dec 16, 12:48 pm, Paul Rogers paul.rog...@shaw.ca wrote: you need to match on the text of the span, not the span itself. @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\]*/) ( i think its the .text method you want, if it gives an undefinedied method error, I got it wrong ;-) ) On Tue, Dec 16, 2008 at 10:28 AM, maven999 maven...@gmail.com wrote: Hi all, I'm trying to grab a string from a block of span text from my UI. The block has SPAN id=db_data and the block is Connected to: Current Database (db_1229419050) Created: Tue, 16 Dec 2008 09:17:30 GMT Next creation: Tue, 16 Dec 2008 15:17:30 GMT I want to grab the db_* string so I can compare it to the value returned by dbi. I have tried: @mytestvalue = $ie.span(:id, 'db_data').matches(/db_\\[0-9\\]*/) but I get the following error on console: NoMethodError: undefined method `matches' for #Watir::Span:0x3790ab0 Does SPAN not support 'matches'? Any idea how I can get this to work? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Need help in accessing an element
Hello All, Please could someone help me with a way to access a link element. Following is the HTML snippet: DIV AIMG/IMGA PA Chelsea Groves Business Cards/A /P P class=pBy by Chelsea Groves /P DIV I need to click on the link with text Chelsea Groves Business Cards. But following is what I actually want to do. I want to click the link before the P tag having text ' by Chelsea Groves', rather then simply clicking on link having text ' Chelsea Groves Business Cards'. Thanks, Natasha --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: 'matches' method for regexp gives error
Sorry, I didn't see the previous message before I posted the above reply. Ravi, it worked! Thanks...so looks like my regexp was wrong all along. Thanks Paul for pointing me to text. Watir forum ROCKS! On Dec 16, 1:16 pm, maven999 maven...@gmail.com wrote: The problem is that db_data is the id for 2 lines of data. The 'db_1229419050' string itself does not have an exclusive id. When I drill down to the string using IE toolbar, I see the following structure: !DOCTYPE HTML PUBLIC -//W3C//DTD HTML Strict//ENMETA http- equiv=Content-Type content=text/html; charset=windows-1252 HTML class=dj_ie dj_ie7BODY class=tundraDIV id=db_top style=PADDING-RIGHT: 10px; FLOAT: right; TEXT-ALIGN: rightSPAN id=db_data (idb_1229440654) /SPAN/DIV/BODY/HTML But clicking on the db_data text in IE toolbar highlights 2 whole lines in UI, instead of JUST 'idb_1229440654'. Does that make sense? On Dec 16, 1:07 pm, Paul Rogers paul.rog...@shaw.ca wrote: what does $ie.span(:id, 'db_data').text return - it might be a problem with your regular expression. What are you expecting @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\]*/) to return ( ie what are you hoping to get back ). he to_s on the end iis unlikely to be needed Paul On Tue, Dec 16, 2008 at 11:02 AM, maven999 maven...@gmail.com wrote: Hi Paul, Thanks for your quick reply. It doesn't work. And neither does it work when I convert the result into string: @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\] */) .to_s I think the problem is the datastructure that the $ie.span(:id, 'db_data') returns. If it is an array, maybe I should be parsing it a different way? On Dec 16, 12:48 pm, Paul Rogers paul.rog...@shaw.ca wrote: you need to match on the text of the span, not the span itself. @mytestvalue = $ie.span(:id, 'db_data').text.matches(/db_\\[0-9\\]*/) ( i think its the .text method you want, if it gives an undefinedied method error, I got it wrong ;-) ) On Tue, Dec 16, 2008 at 10:28 AM, maven999 maven...@gmail.com wrote: Hi all, I'm trying to grab a string from a block of span text from my UI. The block has SPAN id=db_data and the block is Connected to: Current Database (db_1229419050) Created: Tue, 16 Dec 2008 09:17:30 GMT Next creation: Tue, 16 Dec 2008 15:17:30 GMT I want to grab the db_* string so I can compare it to the value returned by dbi. I have tried: @mytestvalue = $ie.span(:id, 'db_data').matches(/db_\\[0-9\\]*/) but I get the following error on console: NoMethodError: undefined method `matches' for #Watir::Span:0x3790ab0 Does SPAN not support 'matches'? Any idea how I can get this to work? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How to handle file download popups in Firefox?
Hello Everyone, Can someone help me with this issue please. I need this working very desperately for my project. Thank you very much. Margam On Dec 15, 2:40 pm, Margam nk.mar...@gmail.com wrote: Hello Everyone, I have been trying to handle File Download pops in FF browser. I had posted a similar question in the FireWatir group (http:// groups.google.com/group/firewatir/browse_thread/thread/ 645846692f7d64fd?ie=utf-8oe=utf-8q=watir+-+file+download+in +Firefox#903516a40a227883), But I thought it would be better here, as I am actually using Watir. My script works successfully until the popup is shown, but does nothing after that. The code is very similar to the one that I use for IE. -- require 'watir' require 'win32ole' Watir::Browser.default='firefox' $browser=Watir::Browser.new def save_file(filename) filepath = c:\\#{File.basename(filename, '.rb')} sleep(10) ai = WIN32OLE.new(AutoItX3.Control) window_title = ai.WinGetTitle([active]) # This is to get the title of the popup. Since this changes in FF, for every file download. sleep 1 ai.ControlFocus(window_title, , OK) sleep 1 ai.ControlClick(window_title, , OK) sleep 1 ai.ControlSend(Enter name of file to save to..., , Edit,filepath) sleep 1 ai.ControlClick(Enter name of file to save to..., , Save) window_title1 = Enter name of file to save to... ai.ControlFocus(window_title1, , Yes) sleep 1 ai.ControlClick(window_title1, , Yes) end $browser.goto(http://abcd.com;) sleep 2 $browser.link(:text, zzz.zip).click sleep 5 save_file(zzz) -- The popup remains and nothing happens. The scripts finishes running without any errors. But the same code works great with IE. Can someone help in pointing the problem here? Also how to control Radio buttons using AutoIt (for the same file download popup). Thank you very much. Margam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Opening an Excel file with a variable name
All, I am attempting to open an Excel file with Ruby, and have run into a problem. If I open the file with single quotes, like inputFile = input.Workbooks.Open('C:\Folder\sheet.xls') everything works fine. My problem now is that the location of the .xls file has a variable name, like inputFile = input.Workbooks.Open(C:\#{var)\sheet.xls). When I try this, I get an error saying that the file cannot be found. It seems that the 'open' method will only work with single quotes, but to signify a variable in a string in Ruby you have to use double quotes. Has anyone discovered a way around this? Thanks in advance for any help. - Shelton --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: Opening an Excel file with a variable name
Try \\ $drive+\\+env+\\Test_Results\\+$file_name+_Results.xls -Original Message- From: watir-general@googlegroups.com [mailto:watir-gene...@googlegroups.com] On Behalf Of jas.shel...@hotmail.com Sent: Tuesday, December 16, 2008 3:08 PM To: Watir General Subject: [wtr-general] Opening an Excel file with a variable name All, I am attempting to open an Excel file with Ruby, and have run into a problem. If I open the file with single quotes, like inputFile = input.Workbooks.Open('C:\Folder\sheet.xls') everything works fine. My problem now is that the location of the .xls file has a variable name, like inputFile = input.Workbooks.Open(C:\#{var)\sheet.xls). When I try this, I get an error saying that the file cannot be found. It seems that the 'open' method will only work with single quotes, but to signify a variable in a string in Ruby you have to use double quotes. Has anyone discovered a way around this? Thanks in advance for any help. - Shelton --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: undefined method `length' for 4324536:Fixnum
I think you need to use a string when setting a text field. Either use to_s to convert the value from fixnum to string when setting the field or use a quoted value in the yml file. --- On Tue, 12/16/08, winstan lucasdavidwinstan...@gmail.com wrote: From: winstan lucasdavidwinstan...@gmail.com Subject: [wtr-general] undefined method `length' for 4324536:Fixnum To: Watir General watir-general@googlegroups.com Date: Tuesday, December 16, 2008, 3:28 PM Hi all, In recent days i have made changes to the way i am storing/using test data within my testcases. Previously i was just setting a cell with a hard coded number within the script but found this to not be the most efficient method for conducting my tests. So i started to use YAML. Its great, it has cleaned up my scripts alot, made it easier to change the test data i wish to use and has forced me into introducing a framework, so all is good. However... When im trying to input specific number into a text field that is sourced from the testdata.yml i get the error: undefined method `length' for 4324536:Fixnum Has any one come across this before, if not could some one indicate what im doing wrong. Here is the line of ruby code: text_field_name_WID.set(data['WidTextField']) Here is the line in the yml file im sourcing: WidTextField: 4324536 Thanks again guys. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: button.Click_No_Wait only highlights the button, does not click
I use the ruby186-26,but still can not handle the popup...Just only block at the commandline. Does someone kindly do me a favor to provide code which can handle the modaldialog?I very appreciate it. I have tried below, but it doestn't work. @ie.button(:value, New).click_no_wait #pop up a modaldialog, by the methodshowmodaldialog sleep(3) hwnd = @ie.enabled_popup(10) @ie1 = @ie.modal_dialog(:title, 'RFQ') The error like this: c:/ruby/lib/ruby/gems/1.8/gems/commonwatir-1.6.2/lib/watir/waiter.rb: 59:in `wait _until': Timed out after 10.032 seconds. (Watir::Exception::TimeOutException) On Dec 16, 7:53 am, HAHAHA windchillfigh...@gmail.com wrote: I tried. The click_no_wait still cannot click the button. I think maybe it is really the configure problem. I use XP SP3, ruby186-27, watir1.6.2. Do you think some earlier version will be better? I know some programs cannot run in current version, like rubyscript2exe.rb. On Dec 16, 3:49 am, pramod D petkar.pra...@gmail.com wrote: Hi, I worked with your code and it is working fine, Only thing you need to do is introduce sleep(5) just before clicking the button. It will handle the pop up. Thanks, Pramod On Mon, Dec 15, 2008 at 8:57 PM, HAHAHA windchillfigh...@gmail.com wrote: Thank you for your code. I test it. But Click_no_wait still cannot work. The result shows There's no popup. Here is the code I used to test. I changed your code to get it. require 'watir' require 'watir/ie'# require 'watir\contrib\enabled_popup' #fafdfs require 'watir/dialog'#fafsfasd require 'watir/winClicker'#fasfsdfa require 'thread' def test_001_Login $batchCode=0 # attach a new browser window $ie = Watir::IE.attach(:url,about:blank) Watir::IE.attach_timeout =10 $ie.goto('http://www.w3schools.com/js/tryit_view.asp? filename=tryjs_alerthttp://www.w3schools.com/js/tryit_view.asp?filename=tryjs_alert') # This website only has an alert button, you can test using this website. $ie.button(:index,1).click_no_wait begin hwnd = $ie.enabled_popup(5) if(hwnd) popup = WinClicker.new popup.makeWindowActive(hwnd) #Activate the window. popup.clickWindowsButton_hwnd(hwnd,OK) #Click the OK button end rescue = e puts e puts There is no popup end end test_001_Login Can you try it and see whether it can work in your computer? Thanks a lot. On Dec 12,10:15 pm, pramod D petkar.pra...@gmail.com wrote: I am posting a sample code which i am using in my script *def test_001_Login $batchCode=0 # attach a new browser window $ie = Watir::IE.attach(:url,about:blank) Watir::IE.attach_timeout = 10.0 ... ... $ie.frame(mains).image(:index,1).click_no_wait begin hwnd = $ie.enabled_popup(5) if(hwnd) popup = WinClicker.new popup.makeWindowActive(hwnd) #Activate the window. popup.clickWindowsButton_hwnd(hwnd,OK) #Click the OK button end rescue = e puts e puts There is no popup end def test_005_logout $ie.frame(header).image(:index,5).click $ie.goto(about:blank) $ie.minimize() end Initially i will open an blank browser manually(This is only for first time) and then in Login method i am attaching it and continue my script, in logout method again i am going to direct browser for balnk page. So nxt time when you re-run the script, blank page is available and script runs smoothly. If i directly open browser from the script it will not work. I am not sure what is the exact problem for time being i am using this approach. * On Fri, Dec 12, 2008 at 8:49 PM, Bret Pettichord b...@pettichord.com wrote: Your code is correct. There is something about your configuration that causes this to fail. Bret HAHAHA wrote: I have tried, using this code: require 'watir' browser = Watir::IE.new browser.goto('http://www.google.com') browser2 = Watir::IE.attach(:title, /Google/) browser2.text_field(:name, 'q').set('Watir') browser2.button(:name, 'btnG').click_no_wait The click_no_wait still cannot run. Is the code right? On Dec 12, 9:58 am, larryni...@gmail.com larryni...@gmail.com wrote: Pramod, could you show us an example of your code? On Dec 11,
[wtr-general] Re: undefined method `length' for 4324536:Fixnum
Thanks John. Some thing as simple as that. Well at least i know now for future references. Oh and all I changed was the data in the yml file so that its quoted. Problem solved. Now onto rexml fun for me... im sure i will be back with questions on that too. Thank god every one around here is so helpful. Thanks again. On Dec 17, 12:10 pm, John Fitisoff jfitis...@yahoo.com wrote: I think you need to use a string when setting a text field. Either use to_s to convert the value from fixnum to string when setting the field or use a quoted value in the yml file. --- On Tue, 12/16/08, winstan lucasdavidwinstan...@gmail.com wrote: From: winstan lucasdavidwinstan...@gmail.com Subject: [wtr-general] undefined method `length' for 4324536:Fixnum To: Watir General watir-general@googlegroups.com Date: Tuesday, December 16, 2008, 3:28 PM Hi all, In recent days i have made changes to the way i am storing/using test data within my testcases. Previously i was just setting a cell with a hard coded number within the script but found this to not be the most efficient method for conducting my tests. So i started to use YAML. Its great, it has cleaned up my scripts alot, made it easier to change the test data i wish to use and has forced me into introducing a framework, so all is good. However... When im trying to input specific number into a text field that is sourced from the testdata.yml i get the error: undefined method `length' for 4324536:Fixnum Has any one come across this before, if not could some one indicate what im doing wrong. Here is the line of ruby code: text_field_name_WID.set(data['WidTextField']) Here is the line in the yml file im sourcing: WidTextField: 4324536 Thanks again guys.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---