Created
January 30, 2015 12:59
-
-
Save manrajgrover/ba1bd439d3d5a59feaaf to your computer and use it in GitHub Desktop.
Selenium script to log in to Facebook and post on wall
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
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
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']"}