У меня есть этот код
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from file import pw
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
class InstaBot:
def __init__(self, username, password):
self.username=username
self.password=password
self.driver = webdriver.Chrome('C://Program Files//webdrivers//chromedriver.exe')
def login(self):
driver=self.driver
driver.get('https://www.instagram.com/')
sleep(2)
username_button=driver.find_element_by_xpath("//input[@name=\"username\"]")
username_button.send_keys(self.username)
password_button=driver.find_element_by_xpath("//input[@name=\"password\"]")
password_button.send_keys(self.password)
password_button.send_keys(Keys.RETURN)
sleep(3)
def page(self,link):
self.driver.get(link)
sleep(3)
def comment(self):
add_comment=WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.XPATH,
'//textarea[@aria-label="Add a comment..."]')))
add_comment.send_keys('hello')
user=InstaBot('myusername' , pw)
user.login()
user.page('https://www.instagram.com/p/B_X4MvogIYljyucO445o8bo8ISdbIuNMRDx8vU0/')
user.comment()
И этот элемент:
<textarea aria-label="Add a comment…" placeholder="Add a comment…" class="Ypffh" autocomplete="off"
autocorrect="off" style="height: 18px;"></textarea>
И я принимаю эту ошибку:
Traceback (most recent call last):
File "botaki.py", line 43, in <module>
user.comment()
File "botaki.py", line 35, in comment
add_comment=WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.XPATH,
'//textarea[@aria-label="Add a comment..."]')))
File "C:\Users\Κώστας Ρότσκας\AppData\Local\Programs\Python\Python38-32\lib\site-
packages\selenium\webdriver\support\wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
В начале все в порядке, Я вхожу и я go на мою страницу в Instagram, но затем я не могу поместить текст в комментарии. Я пробовал все, как ActionsChains, или заменить элемент (aria-label) с заполнителем или с классом, но тоже ничего. Я не знаю, что мне теперь делать с моим ботом в Instagram. Пожалуйста, помогите мне, ребята !!!!!!!