Search code examples
pythonseleniumbuttontwitterreply

Comment on tweet using selenium python webdriver


I'm having trouble replying to a tweet link using selenium and python. I tried find_element_by: id, xpath, class_name and more and not having any luck. I just cantt find the element. Is Twitter making this impossible?


Solution

  • I got it to work:

    driver.get(link)
    number = link.split("/")
    number = number[len(number) - 1]
    driver.find_element_by_id("tweet-box-reply-to-" + number).click()
    driver.find_element_by_id("tweet-box-reply-to-" + number).click()
    driver.find_element_by_id("tweet-box-reply-to-" + number).send_keys(comment)
    driver.find_element_by_id("tweet-box-reply-to-" + number).send_keys(Keys.CONTROL + "\n")