[wtr-general] Webdriver : when i have to grab the id using pattern match it fails for firefox
Hi, I have to grab id's for some of the fileds by pattern matching, because these are dynamic. so to collect the id's, i go to source of that page and grab the id like : $_ = $ie.html if /.*dot.png.*#{fsname}/ printIDInfo("FS ID", $1) This is what i matched from the source generated when IE is opened. Now im using WEbdriver to drive the watir script. If i use this routine and execute the script on IE, it works well. but if i chnage my driver to firefox, then it fails. It is generous that it will fail, because the source generated in firefox is different then IE, what i pattern matched. So how cna i overcome this problem for webdriver? Such that i can grab the id's using patern match and thne execute the script in IE and firefox both. Or even in Chrome. Can someone help? Bhavesh -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Watir Webdriver Performance Error
Yeah I agree RE non-hash return objects... I'l fire up a windows VM this weekend and see if I can pinpoint what's being returned ... stay tuned =) Cheers, Tim On Fri, Dec 9, 2011 at 10:45 AM, Jari Bakken wrote: > On Thu, Dec 8, 2011 at 3:36 AM, @90kts wrote: >> >> Well it appears from the OP error that the return object >> of Browser#execute_script is a WebDriver::Element.. hence my code is failing >> as it expects a hash. >> >> I'm not sure why this is doing it on Win2K8 R2 with IE9, as I don't have >> that development platform... but it was tested on Win2K3 with IE9 as Chuck >> mentioned. >> >> I could just raise an error like Jari suggested, but that won't help the >> outcome (getting navigation timings). >> >> We *could* just monkey patch the execute_script method, but before I do, >> Jari, is there a more elegant solution? >> >> module Watir >> class Browser >> def execute_script(script, *args) >> args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e } >> obj = @driver.execute_script(script, *args) >> obj.each { |k,v| obj[k] = wrap_elements_in(v) } >> obj >> end >> end >> end > > > > Well, execute_script should already wrap instances of > Selenium::WebDriver::Element in Watir::Element, so I'm not sure how that is > happening. > > https://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/browser.rb#L122 > > I don't really see how the monkey patch would help (e.g. it would break any > script that doesn't return a Hash). Someone needs to get their hands on a > Windows box in order to solve this I think :) > > >> >> -- >> Before posting, please read http://watir.com/support. In short: search >> before you ask, be nice. >> >> watir-general@googlegroups.com >> http://groups.google.com/group/watir-general >> watir-general+unsubscr...@googlegroups.com > > > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: Watir Webdriver Performance Error
On Thu, Dec 8, 2011 at 3:36 AM, @90kts wrote: > Well it appears from the OP error that the return object > of Browser#execute_script is a WebDriver::Element.. hence my code is > failing as it expects a hash. > > I'm not sure why this is doing it on Win2K8 R2 with IE9, as I don't have > that development platform... but it was tested on Win2K3 with IE9 as Chuck > mentioned. > > I could just raise an error like Jari suggested, but that won't help the > outcome (getting navigation timings). > > We *could* just monkey patch the execute_script method, but before I do, > Jari, is there a more elegant solution? > > module Watir > class Browser > def execute_script(script, *args) >args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e } >obj = @driver.execute_script(script, *args) >obj.each { |k,v| obj[k] = wrap_elements_in(v) } >obj > end > end > end > Well, execute_script should already wrap instances of Selenium::WebDriver::Element in Watir::Element, so I'm not sure how that is happening. https://github.com/jarib/watir-webdriver/blob/master/lib/watir-webdriver/browser.rb#L122 I don't really see how the monkey patch would help (e.g. it would break any script that doesn't return a Hash). Someone needs to get their hands on a Windows box in order to solve this I think :) > -- > Before posting, please read http://watir.com/support. In short: search > before you ask, be nice. > > watir-general@googlegroups.com > http://groups.google.com/group/watir-general > watir-general+unsubscr...@googlegroups.com > -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: Watir Webdriver Performance Error
I would gladly test this on a few platforms but my selection of handy test VM's is greatly reduced these days as I am no longer working for an MS gold level partner where I had a beefy Hyper-v server hosting a wide variety of Win client and server OS's (all under MSDN licenses). The current employer uses a Linux/Rails platform on the server side, so my VM system are limited to client OS's needed to test the webUI. So unfortunately I can't go back and try this on Server2003 using latest webdriver, IE9 etc. I did look at it on Win7 with current versions of Webdriver and IE9 and got the same error as the OP, so I can assure you the current behavior he's seeing is not limited to the server OS being used. (although there is a fair bit of shared shell code between 2008 and Win7) If there's anything more I can do to help, let me know On Dec 7, 6:36 pm, "@90kts" wrote: > Well it appears from the OP error that the return object > of Browser#execute_script is a WebDriver::Element.. hence my code is > failing as it expects a hash. > > I'm not sure why this is doing it on Win2K8 R2 with IE9, as I don't have > that development platform... but it was tested on Win2K3 with IE9 as Chuck > mentioned. > > I could just raise an error like Jari suggested, but that won't help the > outcome (getting navigation timings). > > We *could* just monkey patch the execute_script method, but before I do, > Jari, is there a more elegant solution? > > module Watir > class Browser > def execute_script(script, *args) > args.map! { |e| e.kind_of?(Watir::Element) ? e.wd : e } > obj = @driver.execute_script(script, *args) > obj.each { |k,v| obj[k] = wrap_elements_in(v) } > obj > end > end > end -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: automate text in Frames Watir with HTML Document
look at the code carefully in the developer tools and make sure you don't have nested frames. In yoursecond posting with the larger code sample it looked like there are at least two levels of frame nesting.. possibly you need to be working with the inner one (not being able to see the actual site, and view the HTML in a proper editor makes it hard to know for sure exactly which element in the code you gave is the actual editor window. You might need to be doing something along the lines of browser.frame(:id => 'englishDescEditor').tframe.etc The exact code you say you are trying would only work if the frame in your app had the title you are specifying, In your code sample I don't find that anywhere other than in a span, so the not able to locate error makes complete sense. you'd need to adapt the code that works on the sample site to fit your site which has different identifiers, titles, id's etc. . On Dec 8, 7:52 am, Erna Tercero wrote: > Hello Chuck > > When i comment the line with the script, then send_keys is the > problem, the thing is i am setting the same to test the CKEditor page, > and it works ok. > > I think the problem is the way i am assigning the frame, > code: > @browser.frame(:title => 'Rich text editor, ckeditor1, press ALT 0 > for help.').send_keys("hello world again") > error: > unable to locate frame/iframe using {:title=>"Rich text editor, > ckeditor1, press ALT 0 for help."} > (Watir::Exception::UnknownFrameException) > > What I can tell you is that my Frames are inside a Form, and in every > frame i have my CKEditor (one in each frame). > > Thank you, if you need some aditional information just let me know. > > On 7 dic, 14:30, Chuck van der Linden wrote: > > > > > > > > > What line of your code is causing the error? is it the > > execute_script one, or the sendkeys? if it's the first one, have > > you tried just using the second? > > > There's a lot of potential problems that could cause this, including > > different javascript or method names depending on what version your > > devs are using vs what you were able to automate against on a sample > > site, and the various options that may be enabled for your editor > > (those things are highly configurable) > > > If sendkeys works you may have to see if there is some way (either via > > a button, or keystrokes) to do a select all followed by delete > > (presuming there is content in the window to start with) and use > > sendkeys to send the content you need to the window. a bit brute > > force but could potentially work. > > > On Dec 6, 7:59 pm, Erna Tercero wrote: > > > > Ok I am back :( > > > > I found some interesting post in the WEB and i got into this: > > > > @browser.execute_script("CKeditor1.instances.'CKeditor1'.setData('hello > > > world');") > > > @browser.frame(:title, "Rich text editor, CKeditor1, press ALT 0 for > > > help.").send_keys "hello world again" > > > > Taken of a post about autamating CKEditor demo page, i can automate > > > the page with no problem, so, when i try to implement something > > > similar into my page is kind of complicated, in chrome i get this > > > error: > > > > Timeout::Error (Timeout::Error) > > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill' > > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill' > > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil' > > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:132:in `readline' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:2551:in `read_new' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1319:in `block in > > > transport_request' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1316:in `catch' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1293:in `request' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1286:in `block in request' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:745:in `start' > > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1284:in `request' > > > > in FF and IExplore i get this error: > > > > unknown error (Selenium::WebDriver::Error::UnexpectedJavascriptError) > > > > so i do not know much about java script, so, can you help me to see if > > > i am implementing this right? > > > > this is my code: > > > > > > > > > > > > lang="en" aria-labelledby="cke_CKEditor1_arialbl" role="application" > > > title=" " dir="ltr" onmousedown="return false;"> > > >
[wtr-general] Re: webdriver - find a window
On Dec 7, 4:41 pm, weimar wrote: > Thanks > browser.windows(:title => "noop").should ==[] worked. > but with the title of your window I presume? (yeah maybe silly to ask, it's the tester in me.. never assume..) -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: automate text in Frames Watir with HTML Document
Hello Chuck When i comment the line with the script, then send_keys is the problem, the thing is i am setting the same to test the CKEditor page, and it works ok. I think the problem is the way i am assigning the frame, code: @browser.frame(:title => 'Rich text editor, ckeditor1, press ALT 0 for help.').send_keys("hello world again") error: unable to locate frame/iframe using {:title=>"Rich text editor, ckeditor1, press ALT 0 for help."} (Watir::Exception::UnknownFrameException) What I can tell you is that my Frames are inside a Form, and in every frame i have my CKEditor (one in each frame). Thank you, if you need some aditional information just let me know. On 7 dic, 14:30, Chuck van der Linden wrote: > What line of your code is causing the error? is it the > execute_script one, or the sendkeys? if it's the first one, have > you tried just using the second? > > There's a lot of potential problems that could cause this, including > different javascript or method names depending on what version your > devs are using vs what you were able to automate against on a sample > site, and the various options that may be enabled for your editor > (those things are highly configurable) > > If sendkeys works you may have to see if there is some way (either via > a button, or keystrokes) to do a select all followed by delete > (presuming there is content in the window to start with) and use > sendkeys to send the content you need to the window. a bit brute > force but could potentially work. > > On Dec 6, 7:59 pm, Erna Tercero wrote: > > > > > Ok I am back :( > > > I found some interesting post in the WEB and i got into this: > > > @browser.execute_script("CKeditor1.instances.'CKeditor1'.setData('hello > > world');") > > @browser.frame(:title, "Rich text editor, CKeditor1, press ALT 0 for > > help.").send_keys "hello world again" > > > Taken of a post about autamating CKEditor demo page, i can automate > > the page with no problem, so, when i try to implement something > > similar into my page is kind of complicated, in chrome i get this > > error: > > > Timeout::Error (Timeout::Error) > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill' > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill' > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil' > > C:/Ruby/lib/ruby/1.9.1/net/protocol.rb:132:in `readline' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:2551:in `read_new' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1319:in `block in > > transport_request' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1316:in `catch' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1293:in `request' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1286:in `block in request' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:745:in `start' > > C:/Ruby/lib/ruby/1.9.1/net/http.rb:1284:in `request' > > > in FF and IExplore i get this error: > > > unknown error (Selenium::WebDriver::Error::UnexpectedJavascriptError) > > > so i do not know much about java script, so, can you help me to see if > > i am implementing this right? > > > this is my code: > > > > > > > > lang="en" aria-labelledby="cke_CKEditor1_arialbl" role="application" > > title=" " dir="ltr" onmousedown="return false;"> > >
[wtr-general] Re: Safari Getting Table Cell Text
Sorry I put down the wrong error message. I'm actually getting /Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir/ scripter.rb:189:in `find_cell': uninitialized constant Watir::JavaScripter::MissingWayOfFindingObjectException (NameError) My code: require 'rubygems' require 'safariwatir' @b = Watir::Safari.new @b.goto(my_webpage) cell = @b.table(:class, "user-table")[0][1] #getting row 0 cell 1 puts cell.text I followed all the instructions on this page https://github.com/zeljkofilipin/watirbook/blob/master/installation/mac.md All of my gems are up to date. Thanks for your help On Dec 8, 4:49 am, Željko Filipin wrote: > On Wed, Dec 7, 2011 at 5:32 PM, Brad wrote: > > It seems like this should be working > > cell = @b.table(:class, "user-table")[0][1] #getting row 0 cell 1 > > puts cell.text > > O have replied at SO: > > http://stackoverflow.com/questions/8419360/getting-cell-text-from-a-t... > > Željko > -- > watir.com/book - author -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Safari Getting Table Cell Text
On Wed, Dec 7, 2011 at 5:32 PM, Brad wrote: > It seems like this should be working > cell = @b.table(:class, "user-table")[0][1] #getting row 0 cell 1 > puts cell.text O have replied at SO: http://stackoverflow.com/questions/8419360/getting-cell-text-from-a-table-using-watir-on-mac-safari Željko -- watir.com/book - author -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com