python - 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()
解决方案
推荐阅读
- spring-boot - JpaRepostory existsXXX 方法无法正常工作
- wordpress - Wordpress DIVI 主题 - 无法添加图像(未捕获的类型错误:无法读取未定义的属性“替换”)
- ios - 如何在 Swift 中无约束地调整按钮大小?
- haskell - 前缀或中缀:在 Haskell 中哪个是惯用的?
- regex - 使用包含空格 (\s) 和 sed 的正则表达式变量
- go - 将类型结构 A 转换为 B
- c# - 实体框架 6 App.config 文件未创建
- firebase - 如何将 Firebase 身份验证令牌用于 YouTube API 访问令牌
- ffmpeg - 是否可以在 UWP 中将 MediaTransportControls 与 FFmpegInterop 一起使用?
- reactjs - 如何在 React 应用程序中的所有 onclick 处理程序之前运行通用代码?(解决 Safari 中键单击错误)