My code:
def follow_user(username):
driver.get(f"https://x.com/{username}")
time.sleep(2)
follow = EC.element_to_be_clickable((By.XPATH, '//span[text()="Follow"]'))
follow.click()
got error:
AttributeError: 'function' object has no attribute 'click'
Can anyone help?
Tried By.CSS_SELECTOR
, same error.
You should wrap it up with WebDriverWait
:
from selenium.webdriver.support.wait import WebDriverWait
def follow_user(username):
driver.get(f"https://x.com/{username}")
time.sleep(2)
wait = WebDriverWait(driver, 10)
follow = wait.until(EC.element_to_be_clickable((By.XPATH, '//span[text()="Follow"]')))
follow.click()