Thursday, January 29, 2015

Facebook login & Logout using Selenium python


from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("https://facebook.com")

email = "email"
password = "pass"
login="loginbutton"
emailelement = driver.find_element_by_name(email)
passwordelement = driver.find_element_by_name(password)
emailelement.send_keys("##username###")
passwordelement.send_keys("##password###")
loginelement = driver.find_element_by_id(login)
loginelement.click()
drop="userNavigationLabel"
dropelement = driver.find_element_by_id(drop)
dropelement.click()
logout="uiLinkButtonInput"
logoutelement = driver.find_element_by_class_name(logout)
logoutelement.click()

6 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. This comment has been removed by a blog administrator.

    ReplyDelete
  3. logout is not working can u plz confirm it.

    ReplyDelete
    Replies
    1. ok i solved it in different method.

      Delete
    2. This comment has been removed by a blog administrator.

      Delete