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