Last active
April 26, 2020 00:01
-
-
Save pranshuj73/1d2976da8c81aa7c55291e3e8bea7960 to your computer and use it in GitHub Desktop.
code section 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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