使用硒和python发布到Facebook墙
我正在windows 7上使用firefox 18.0和selenium webdriver与python(2.7)绑定。使用所有这一切,我已经能够登录到Facebook,转到用户的页面,发送文本到墙上的字段。但是当我让它点击发布,它不发布。我已经观察到,当我把钥匙发送到墙上的字段时,文本显示为褪色,但是当我手动输入字段时,文本看起来很暗。这可能是问题。我开始这样做,看是否可以完成...没有真正的目的..但现在它不起作用,它驱使我疯狂。任何想法?
I am using firefox 18.0 and selenium webdriver with python(2.7) bindings on windows 7. Using all this I have been able to log in to facebook, go to an user's page , send text to the wall post field. but when i make it click post, it doesn't post. I have observed that when I send the keys to the wall post field, the text appears faded, but when i manually type into the field, the text appears dark. This might be the problem. I started doing this to see if it could be done...for no real purpose.. but now that it doesn't work, its driving me crazy. Any ideas?
driver = self.driver
driver.get("https://www.facebook.com/")
driver.find_element_by_id("email").clear()
driver.find_element_by_id("email").send_keys("mailid@email.com")
driver.find_element_by_id("pass").clear()
driver.find_element_by_id("pass").send_keys("password")
driver.find_element_by_id("u_0_4").click()
#i wanted to post multiple times.. but it doesn't work even once
for i in range(1,11):
driver.get("https://www.facebook.com/<username>")
el=driver.find_element_by_id("u_0_1r")#post field
el.clear()
print i
el.click()
el.clear()
el.send_keys(Keys.RETURN)
time.sleep(1)
el.click()
#assume fwords is a list of words
el.send_keys('test output: '+random.choice(fwords))
el.click()
el.click()
time.sleep(2)
driver.find_element_by_id("u_0_1m").click()
driver.find_element_by_xpath("//form[@id='u_0_1l']/div/div[4]/div/ul/li[2]/label/input").click()
time.sleep(8)
它适用于硒驱动程序。