Hi, I notice you are using click_no_wait when submitting your gmail credentials. Could it be that your script moves on to the next line (finding the iframe) before the browser has finished loading the main document after login? What happens if you replace click_no_wait with click?
But even if that is fixed, you may find that the script fails when locating the 'Send' button. (That is where it breaks down for me today.) I found a post on a selenium mailing list in June where someone complained of the same problem. I posted the original wiki page with this code, but since then it's become obvious that gmail is a moving target that is tough to hit. :) It seems to me that the gmail team is either actively trying to discourage casual automation, or at least has no interest in making it easy. So I am considering removing the wiki page I wrote on this topic, mainly because the code doesn't work anymore - and even if it were made to work today, it would probably break again soon due to future gmail changes. Any contrary opinions? Thanks Bill On Mon, Aug 17, 2009 at 11:10 PM, shailesh <[email protected]> wrote: > > I am a new user of Watir. I did not get the solution thread so posting > here: > This is a program to automate gmail to compose mail and check in the > sent item but it gives the following error : > > >ruby autogmail.rb > Loaded suite autogmail > Started > E > Finished in 11.454 seconds. > > 1) Error: > test_gmaildemo(GmailDemo): > Watir::Exception::UnknownFrameException: Unable to locate a frame with > id canvas_frame > c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/frame.rb: > 40:in `locate' > c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/frame.rb: > 47:in `initialize' > c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/container.rb: > 102:in `new' > c:/ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/container.rb: > 102:in `frame' > autogmail.rb:13:in `test_gmaildemo' > > 1 tests, 0 assertions, 0 failures, 1 errors > >Exit code: 1 > > > The original code is available in watir simple examples : > > require 'test/unit' > require 'watir' > > class GmailDemo < Test::Unit::TestCase > def test_gmaildemo > ie = Watir::IE.new > ie.goto('mail.google.com') > ie.text_field(:name,'Email').set("[email protected]") > ie.text_field(:name,'Passwd').set("password") > ie.button(:name,'signIn').click_no_wait > > # We need the iframe with ID 'canvas_frame'. Store it in a var. > canvas_frame = ie.frame(:id, 'canvas_frame') > > # Get the current user's email address. We'll be sending email to > it. > my_address = canvas_frame.div(:id, 'guser').text.slice(/^...@gmail > \.com/) > mail_subject = 'Hello Watir world!' > mail_body_text = 'Hi.' > > canvas_frame.span(:text, 'Compose Mail').click # Compose new mail > canvas_frame.text_field(:name, 'to').set(my_address) > canvas_frame.text_field(:name, 'subject').set(mail_subject) > # The mail body field is contained in its own iframe, which only > contains > # a body element. So, save the iframe in a var, then set the > innerText > # property of the iframe's body element. > mail_body_frame = canvas_frame.frame(:index, 1) > # TODO: there must be a friendlier way to do this, while still > avoiding > # hardcoding of any unfriendly identifiers. Does Watir need a body > method? > mail_body_frame.document.body.setproperty('innerText', > mail_body_text) > > canvas_frame.button(:text, 'Send').click # Send the message > canvas_frame.link(:text, 'Sent Mail').click # Browse to sent mail > page > assert(canvas_frame.contains_text('Hello Watir world!')) > canvas_frame.link(:text, /Inbox/).click # Return to the inbox > page > ie.close > end > end > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to [email protected] Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---
