首页 > 解决方案 > python web bot selenium虽然无法将其发布到postug

问题描述

您好,我正在尝试打开我的 webdriver 并在 facebook 帐户上发布代码,但我无法弄清楚为什么我的按钮标签和帖子文本不起作用,请帮助我。

这是不工作的部分,但其他一切工作,它一直说按钮不能被点击

buttons = driver.find_elements_by_tag_name('button')
for button in buttons:
    if 'Post' in button.text:
        button.click()
    driver.quit()

块引用

#imports webdriver from selenium 
from selenium import webdriver

#creates web driver
driver= webdriver.Chrome()


#creates window for facebook
driver.get("https://facebook.com")



#finds the element with name and enters email 
element = driver.find_element_by_name("email")
element.send_keys("someemail@gmail.com")

#finds the element by name and enters password
el2= driver.find_element_by_name("pass")
el2.send_keys("somePassword")


#finds button to log on and clicks it
el3 = driver.find_element_by_id("u_0_b")
el3.click()

#finds xpath to put message in tab window for posting
el3 = driver.find_element(By.XPATH, "//*[@name='xhpc_message']")
el3.send_keys("Ryan's Python bot was here 5/19/2020")

#waits for the page to load
driver.implicitly_wait(10)


#clicks button to Post but does not work
buttons = driver.find_elements_by_tag_name('button')
    for button in buttons:
        if 'Post' in button.text:
            button.click()
driver.quit()

标签: pythonseleniumwebdriver

解决方案


推荐阅读