Skip to content

Instantly share code, notes, and snippets.

@pranshuj73
Last active April 26, 2020 00:01
Show Gist options
  • Save pranshuj73/1d2976da8c81aa7c55291e3e8bea7960 to your computer and use it in GitHub Desktop.
Save pranshuj73/1d2976da8c81aa7c55291e3e8bea7960 to your computer and use it in GitHub Desktop.
code section 3
# This function is a part of Tweeter class which will allow us to tweet
def tweet(self):
tweet_text = input("Enter your tweet here: ")
driver = self.driver
sleep(3)
# finds the compose tweet button
tweet_btn = driver.find_element_by_xpath("//a[@aria-label=\"Tweet\"]")
tweet_btn.click()
sleep(2)
# This will type text in the text field
tweet_field = driver.find_element_by_xpath("//div[@aria-label=\"Tweet text\"]")
tweet_field .click()
sleep(1)
tweet_field.send_keys(tweet_text)
# sends the tweet
tweetbtn = driver.find_element_by_xpath("//*[contains(text(),'Tweet')]")
tweetbtn.click()
sleep(1)
# success message
print("Your tweet has been tweeted!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment