简体   繁体   English

selenium.common.exceptions.NoSuchElementException

[英]selenium.common.exceptions.NoSuchElementException

[I try to make Twitter Bot but always become this Error Can anyone Help! thank you!][1]

Image图片

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep

driver = webdriver.Chrome(executable_path=r"\Users\3shal\OneDrive\Desktop\twitterbot\chromedriver")
driver.get("https:twitter.com/")
sleep(5)

driver.find_element_by_name('session[username_or_email]').send_keys("")
driver.find_element_by_name('session[password]').send_keys("")
driver.find_element_by_name('session[password]').send_keys(Keys.RETURN)
sleep(5)


f = open("contant.txt", 'r')

for word in f:
if word == "\n":
    continue
driver.find_element_by_xpath("//a[@data=testid='SideNav_NewTweet_Button']").click()


sleep(5)
driver.find_element_by_class_name("notranslate").click()
driver.find_element_by_class_name("notranslate").send_keys(word)
driver.find_elements_by_xpath("//div[@data=testid='tweetButton']").click()
sleep(5)

f.close()

try to make Twitter Bot but always become this Error and yes i checked the chrome version and updated everything Can anyone Help!尝试制作 Twitter Bot 但总是成为此错误,是的,我检查了 chrome 版本并更新了所有内容 谁能帮忙! thank you!谢谢你!

You have small typo in your xpath.您的 xpath 中有小错字。

driver.find_elements_by_xpath("//div[@data-testid='tweetButton']").click()

It not data=testid , it's data-testid .它不是data=testid ,它是data-testid Fixing this should solve your problem.解决这个问题应该可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium 中的 selenium.common.exceptions.NoSuchElementException - selenium.common.exceptions.NoSuchElementException in Selenium selenium.common.exceptions.NoSuchElementException:消息: - selenium.common.exceptions.NoSuchElementException: Message: 如何修复selenium.common.exceptions.NoSuchElementException? - How to fix selenium.common.exceptions.NoSuchElementException? “错误:selenium.common.exceptions.NoSuchElementException:消息 - "Error: selenium.common.exceptions.NoSuchElementException: Message Selenium 使用 Chrome 时出现“selenium.common.exceptions.NoSuchElementException” - Selenium "selenium.common.exceptions.NoSuchElementException" when using Chrome Selenium.common.exceptions.NoSuchElementException 错误,即使显式等待 - Selenium.common.exceptions.NoSuchElementException error even with explicit waiting 动态内容中的selenium.common.exceptions.NoSuchElementException - selenium.common.exceptions.NoSuchElementException from dynamic content selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素 - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法定位元素: - selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: 如何修复“selenium.common.exceptions.NoSuchElementException” - How can I fix "selenium.common.exceptions.NoSuchElementException"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM