Merhaba, Pythonda twitterda gönderiye yorum yapmak için bi bot yazmaya çalışıyorum ancak yorum yazma yerinin XPATH kodunu aldığımda bir türlü çalışmıyor nedeni nedir?
Kod:
from selenium import webdriver
import time
browser = webdriver.Firefox()
browser.get('https://twitter.com')
time.sleep(5)
userdosya = open("bilgiler\\user.txt")
usersatir = userdosya.readlines()
print(usersatir[0])
passdosya = open("bilgiler\\password.txt")
passsatir = passdosya.readlines()
print(passsatir[0])
while (usersatir != ""):
giristekrarlabutton = browser.find_element_by_xpath("/html/body/div/div/div/div[2]/main/div/div/div[1]/div[1]/div/div[3]/div[5]/a")
giristekrarlabutton.click()
time.sleep(5)
mailtext = browser.find_element_by_xpath('/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[5]/label/div/div[2]/div/input')
mail_ileri = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[6]/div")
mailtext.send_keys(usersatir[0])
time.sleep(2)
mail_ileri.click()
time.sleep(2)
passwordtext = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[3]/div/label/div/div[2]/div[1]/input")
passwordtext.send_keys(passsatir[0])
time.sleep(2)
girisbutton = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[2]/div/div[1]")
girisbutton.click()
time.sleep(5)
browser.execute_script("window.open('https://twitter.com/elonmusk/status/1508111817079341056')")
time.sleep(15)
yanit1 = browser.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/main/div/div/div/div[1]/div/section/div/div/div[1]/div/div[1]/article/div/div/div/div[3]/div[5]/div/div[1]/div/div/div/div")
yanit1.click()
"""""
Hata :
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:19: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
giristekrarlabutton = browser.find_element_by_xpath("/html/body/div/div/div/div[2]/main/div/div/div[1]/div[1]/div/div[3]/div[5]/a")
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:23: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
mailtext = browser.find_element_by_xpath('/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[5]/label/div/div[2]/div/input')
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:24: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
mail_ileri = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[6]/div")
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:30: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
passwordtext = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[1]/div/div/div[3]/div/label/div/div[2]/div[1]/input")
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:33: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
girisbutton = browser.find_element_by_xpath("/html/body/div/div/div/div[1]/div/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div[2]/div/div[1]")
C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py:39: DeprecationWarning: find_element_by_xpath is deprecated. Please use find_element(by=By.XPATH, value=xpath) instead
yanit1 = browser.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/main/div/div/div/div[1]/div/section/div/div/div[1]/div/div[1]/article/div/div/div/div[3]/div[5]/div/div[1]/div/div/div/div")
Traceback (most recent call last):
File "C:\Users\Ahmett\PycharmProjects\Project\Otomatik çekiliş.py", line 39, in <module>
yanit1 = browser.find_element_by_xpath("/html/body/div[1]/div/div/div[2]/main/div/div/div/div[1]/div/section/div/div/div[1]/div/div[1]/article/div/div/div/div[3]/div[5]/div/div[1]/div/div/div/div")
File "C:\Users\Ahmett\PycharmProjects\Project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 521, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\Ahmett\PycharmProjects\Project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 1248, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\Ahmett\PycharmProjects\Project\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "C:\Users\Ahmett\PycharmProjects\Project\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: /html/body/div[1]/div/div/div[2]/main/div/div/div/div[1]/div/section/div/div/div[1]/div/div[1]/article/div/div/div/div[3]/div[5]/div/div[1]/div/div/div/div
Stacktrace:
WebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:183:5
NoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:395:5
element.find/</<@chrome://remote/content/marionette/element.js:300:16