Simple Steps:
1. Go to http://mail.google.com
2. Enter your user name 'yourgmailid'
3. Enter your password 'yourpassword'
4. Login
5. Goto Sent mail
6. Logout
Simple Code:
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver= webdriver.Chrome("E:\QA\Resource\WEBDRIVER\chromedriverserver\chromedriver.exe")
driver.get("http://mail.google.com")
emailid=driver.find_element_by_id("Email")
emailid.send_keys("yourgmailid")
passw=driver.find_element_by_id("Passwd")
passw.send_keys("yourpassword")
signin=driver.find_element_by_id("signIn")
signin.click()
time.sleep(10)
driver.switch_to_frame('canvas_frame')
sentmail= driver.find_element_by_link_text('Sent Mail')
sentmail.click()
time.sleep(10)
sentmail= driver.find_element_by_link_text('Your Name')
sentmail.click()
lout= driver.find_element_by_link_text('Sign out')
lout.click()
Simple explanation:
driver= webdriver.Chrome("E:\QA\Resource\WEBDRIVER\chromedriverserver\chromedriver.exe")
can also use
driver= webdriver.Firefox() or
driver= webdriver.Ie()
Choose your destination:
driver.get("http://mail.google.com")
Find element:
emailid=driver.find_element_by_id("Email")
how?
<input id="Email" type="text" value="" name="Email" spellcheck="false">
or?
<input id="Email" type="text" value="" name="Email" spellcheck="false">
emailid=driver.find_element_by_name("Email")
more? YES
find_element_by_xpath
find_element_by_css_selector
find_element_by_class_name
find_element_by_link_text
etc
Enter text:
remember from selenium.webdriver.common.keys import Keys?
emailid.send_keys("yourgmailid")
Handle iframe:
driver.switch_to_frame('canvas_frame')
How?<iframe id="canvas_frame" class="cO" frameborder="0" title="main" src="?ui=2&view=bsp&ver=ohhl4rw8mbn4" name="c1uzah0zrv218y">
For first part visit Hello World! WebDriver with Python on Win 7
For first part visit Hello World! WebDriver with Python on Win 7
This comment has been removed by the author.
ReplyDeleteWrong comment earlier. Very good initiative :)
ReplyDeleteThanks a lot
ReplyDeleteI used these lines in ruby:
ReplyDelete@selenium = Selenium::SeleniumDriver.new 'localhost' , 4444, '*firefox' , 'http://www.gmail.com' , 10000
@selenium.type "Email", "yourid"
@selenium.type "Passwd", "yourpassword"
@selenium.click "//input[@value='Sign in']"
@selenium.wait_for_page_to_load "30000"
sleep 5
@selenium.click "link=Sent Mail"
@selenium.click "link=yourprofilename"
@selenium.click "link=Sign out"
@selenium.wait_for_page_to_load "30000"
Good initiative bhaiya (Y)
ReplyDeleteআল আরমান I guess you are using Selenium RC, right?
ReplyDeleteFor Webdriver ruby bindings
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :firefox
by the way after 'sleep 5'
ReplyDeleteyou need to select iframe 'canvas_frame', when exporting code from IDE this part always skipped. :)
Merci
ReplyDeleteaswqergh
Probably one of the most talked about stores in Paris,Isabel Marant Sneakers
wesofttech.com Call 1-888-505-6485 (Toll Free) for Gmail Technical Support.Gmail Password Recovery, Gmail Tech Support, Gmail support number and Gmail Help etc.
ReplyDeleteVisit Link- Gmail Support
hi thanks to this writer for this nice blog and this good information
ReplyDeleteother useful link - Gmail Tech Support
I have a smart solution for this using Selenium IDE. I could go to composer text area by just using its class (class=editable LW-avf). For detailed article, please refer to http://www.seleniumhq.in/2013/04/automatically-login-to-gmail-and-send.html
ReplyDelete