-
-
Save qustosh/8451767 to your computer and use it in GitHub Desktop.
Use selenium to auto login gmail account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
driver= webdriver.Firefox() | |
#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("username") | |
passw=driver.find_element_by_id("Passwd") | |
passw.send_keys("password") | |
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Can you check as why my element of password is not found.
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
#url = input('Enter the URL: ')
loginname=input('Enter Email Id:')
gmailpassword=input('Enter Password:')
driver= webdriver.Chrome()
driver.get('http://www.gmail.com/')
print ("Opened Gmail")
sleep(1)
emailid=driver.find_element_by_id("identifierId")
emailid.send_keys(loginname)
print ("Email Id entered")
sleep(1)
driver.find_element_by_xpath('//*[@id="identifierNext"]/content').click()
passw=driver.find_element_by_xpath('//*[@id="password"]/div[2]').click()
#passw=driver.find_element_by_xpath('/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[1]/div/form/content/div[1]/div/div[1]/div/div[1]/input').clear()
passw.send_keys(gmailpassword)
signin=driver.find_element_by_name("//*[@id='password']/div[1]/div/div[1]/input")
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()