Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda