Skip to content

Instantly share code, notes, and snippets.

@kmandana
Created April 18, 2020 20:22
Show Gist options
  • Select an option

  • Save kmandana/dd7f39860b844887f024ae9182bd8d12 to your computer and use it in GitHub Desktop.

Select an option

Save kmandana/dd7f39860b844887f024ae9182bd8d12 to your computer and use it in GitHub Desktop.
Sending Message
def send_likes(self, usernames):
for username in usernames:
url = 'https://www.instagram.com/' + username
self.browser.get(url)
button = self.browser.find_element_by_css_selector('button')
if button.text == "Message":
button.click()
text_box = WebDriverWait(self.browser, 5).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.DPiy6.Igw0E.IwRSH.eGOV_.vwCYk > div.uueGX > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.Igw0E.IwRSH.eGOV_.vwCYk.ItkAi > textarea")))
text_box.send_keys(self.msg)
send_button = self.browser.find_element_by_css_selector('#react-root > section > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.DPiy6.Igw0E.IwRSH.eGOV_.vwCYk > div.uueGX > div > div.Igw0E.IwRSH.eGOV_._4EzTm > div > div > div.Igw0E.IwRSH.eGOV_._4EzTm.JI_ht > button')
send_button.click()
print('Message sent succesfully to", username)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment