On Saturday, January 24, 2015 at 2:55:32 PM UTC-8, Bhuvan Sundar wrote: > > Hi All, > > I am new to Ruby.Just beginner.Started with below procedure > > 1. installed Ruby 1.9.3 version on windows 7 > 2.installed watir-webdriver > > had written code for gmail login on chrome.Here my problem is unable to > set the value to field Email text box.please let me know anything is wrong > in below code > > require 'watir-webdriver' > > CM=Watir::Browser.new :chrome > CM.goto "https://www.gmail.com" > > CM.driver.manage.window.maximize > CM.driver.manage.timeouts.implicit_wait=5 > > CM.text_field(:id,"Email").when_present_Set "a" > CM.text_field(:id,"Passwd").set "b" > > CM.button(:id,"ignIn").Click > Thanks, > Bhuvan > > > > 1) I presume you have replaced real values with 'a' and 'b' (since of course 'a' is not a valid email address, and 'b' would be a stupidly bad password.
2) style nitpick: in ruby, variables named in all caps are normally presumed to be constants.. it's not strictly enforced but will drive anyone reviewing your code batty to see such like 'CM' all over the place if the value is not in fact a constant. 3) maybe you are getting a different experience than me depending on where you are in the world, or browser, but when not logged in, there are no sign-in fields on the main gmail.com page, you have to click a link to sign in and that takes you to a different page (https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/) 4) likely the cause of your issue: ".when_present_Set" is not a method. you want ".when_present.set" (two methods, one after the other) 5) potentially a second problem once you fix the first. again maybe a different sign in page, but on the one I see, the button to submit the credentials as an ID of 'signIn' not "ignIn" correcting for the above, I would expect the last three lines of your script to be cm.text_field(:id,"Email").when_present.set "[email protected]" cm.text_field(:id,"Passwd").set "yourpassword" cm.button(:id,"signIn").click -- -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected] --- You received this message because you are subscribed to the Google Groups "Watir General" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
