Basic setup required:
First we need to do basic setup of python and the "selenium" module installation.
pip install selenium
Following code is used to login and logout from a GMAIL account:
# Modules to be imported.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Your login details.
email = "<email>@gmail.com"
passwd = "<your password>"
# Browser : Firefox.
driver = webdriver.Firefox()
driver.get("http://www.gmail.com")
time.sleep(2)
# GMAIL login.
username=driver.find_element_by_css_selector("#Email")
username.send_keys(email)
time.sleep(2)
next=driver.find_element_by_css_selector("#next")
next.click()
time.sleep(2)
password=driver.find_element_by_css_selector("#Passwd")
password.send_keys(passwd)
time.sleep(2)
login=driver.find_element_by_css_selector("#signIn")
login.click()
# GMAIL logout.
logout1=driver.find_element_by_css_selector(".gb_8a")
logout1.click()
time.sleep(2)
logout2=driver.find_element_by_css_selector("#gb_71")
logout2.click()
# Closing Browser.
driver.quit()
First we need to do basic setup of python and the "selenium" module installation.
For basic python setup see the following video's:
- Python installation : https://www.youtube.com/watch?v=HNKQev4KLGE
- Pip installation to install new modules : https://www.youtube.com/watch?v=lJD38DjY1Cg
Installation of selenium module using pip:
For installing a python module see the following video : https://www.youtube.com/watch?v=5zEQaYBukz4
pip install selenium
Following code is used to login and logout from a GMAIL account:
# Modules to be imported.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Your login details.
email = "<email>@gmail.com"
passwd = "<your password>"
# Browser : Firefox.
driver = webdriver.Firefox()
driver.get("http://www.gmail.com")
time.sleep(2)
# GMAIL login.
username=driver.find_element_by_css_selector("#Email")
username.send_keys(email)
time.sleep(2)
next=driver.find_element_by_css_selector("#next")
next.click()
time.sleep(2)
password=driver.find_element_by_css_selector("#Passwd")
password.send_keys(passwd)
time.sleep(2)
login=driver.find_element_by_css_selector("#signIn")
login.click()
# GMAIL logout.
logout1=driver.find_element_by_css_selector(".gb_8a")
logout1.click()
time.sleep(2)
logout2=driver.find_element_by_css_selector("#gb_71")
logout2.click()
# Closing Browser.
driver.quit()
Note:
Keep seeing my blog for different automation thing that we do manually in our daily life.
To go with the sleek Gmail Redesign login Send GMail Emails and reduce the number of folders on your left side panel, we removed our Tracked folder. You can still find all tracked emails inside your Sent folder.
ReplyDeleteIt’s really Nice and Meaningful. It’s really cool Blog. You have really helped lots of people who visit Blog and provide them Useful Information. Thanks for Sharing.DataScience with Python Training in Bangalore
ReplyDelete