我在 Windows 7 上使用带有 python(2.7) 绑定的 firefox 18.0 和 selenium webdriver。使用所有这些我已经能够登录到 facebook,转到用户页面,将文本发送到墙上的帖子字段。但是当我让它点击发布时,它不会发布。我观察到,当我将密钥发送到墙上的帖子字段时,文本看起来很褪色,但是当我手动输入字段时,文本看起来很暗。这可能是问题所在。我开始这样做是为了看看是否可以这样做......没有真正的目的......但现在它不起作用,它让我发疯。有任何想法吗?
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)