Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahmedjawed01/2f77d21df28bb3a6823f6126d80041fb to your computer and use it in GitHub Desktop.
Save ahmedjawed01/2f77d21df28bb3a6823f6126d80041fb to your computer and use it in GitHub Desktop.
Selenium script to log in to Facebook and post on wall
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.common.exceptions import NoSuchElementException
driver = webdriver.Firefox()
driver.get('https://www.facebook.com/')
print "Opened facebook..."
a = driver.find_element_by_id('email')
a.send_keys('Your email id')
print "Email Id entered..."
b = driver.find_element_by_id('pass')
b.send_keys('Your password')
print "Password entered..."
c = driver.find_element_by_id('loginbutton')
c.click()
driver.get("https://www.facebook.com/apoorvu")
post_box=driver.find_element_by_xpath("//*[@name='xhpc_message']")
post_box.click()
post_box.send_keys("Testing using Name not ID.Selenium is easy.")
sleep(2)
post_it=driver.find_element_by_xpath("//*[@id='u_0_1a']/div/div[6]/div/ul/li[2]/button")
post_it.click()
print "Posted..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment