Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

137
Views
Instagram selenium post button not working

I recently used selenium code to post a comment on one of my favorite posts. Everything works fine except when the comment is written in the text field and it must then be posted. how can I fix this issue?

 driver.find_element_by_class_name('Ypffh').click()  # click the field to insert comment
 field = driver.find_element_by_class_name('Ypffh')
 field.clear()
 typephrase(comment[counter], field)  
 sleep(delay)

The blow code does not work for posting comments. How can I fix it?

driver.find_element_by_xpath('//button[contains(text(), "Post")]').click()  # click the post 'comment' button element
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If it is a comment you are trying to post then I believe you don't have to click the post button, you could instead send the enter key to the text box element and this will post the comment. This will also be helpful, because it will still work if they ever change the HTML x-path of the post button element.

This is how I would do it, using your code from the first part:

from selenium.webdriver.common.keys import Keys

driver.find_element_by_class_name('Ypffh').click()  # click the field to insert comment
field = driver.find_element_by_class_name('Ypffh')
field.clear()
typephrase(comment[counter], field)  
sleep(delay)

field.send_keys(Keys.ENTER)

I hope that helps, sorry if it doesn't!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!