Skip to content

Instantly share code, notes, and snippets.

@manrajgrover
Created January 30, 2015 12:59
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save manrajgrover/ba1bd439d3d5a59feaaf to your computer and use it in GitHub Desktop.
Save manrajgrover/ba1bd439d3d5a59feaaf 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..."
@danyarango1999
Copy link

I have the same error with Can't locate item: {"method": "xpath", "selector": "// * [@ name = 'xhpc_message_text']"}
is to create a publication in the group someone I can solve who can help me
Unable to locate element: {"method":"xpath","selector":"//*[@name='xhpc_message_text']"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment