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

424
Views
Can't press a phenomenical easy button with selenium python

I need some help with pressing this button. In this page the button "cersa" is untraceable with selectors.

https://www.consiglionazionaleforense.it/ricerca-avvocati

I also used JS code that in the console it works but in the python script it crashes with:

selenium.common.exceptions.JavascriptException: Message: javascript error: Cannot read properties of undefined (reading 'click')

the js script:

    js_code = "button = document.getElementsByClassName('btn-link btn-link--green mt-4'); button[0].click();"
    driver.execute_script(js_code)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This should work

   driver.execute_script("document.getElementsByClassName('btn-link btn-link--green mt-4').click()")

I am not sure why you are intending to go with execute_script, but if you can go with the direct selenium, then you may use this:

driver.find_element(By.XPATH, "//div[@id='ricerca-avvocati']//button[@type='submit']").click()

UPDATE:

I did a keen testing on the issue of why the button is not clicking even though the element is found in the DOM.

The issue is, the element is not clickable at all, unless you click on the I am not a robot checkbox, which if clicked by automation (or a bot) may not work (as websites detect the bot actions). Try clicking on the reCaptcha I am not a robot checkbox, and if you are not detected as a bot, then the element would become clickable and the action would be fulfilled.

I used regular click function - the one that I gave you as a second code block, and it works, but I had to manually force click on the reCaptcha checkbox - only then it worked. As you can see, the code exited with 0 code, which mean no errors. But the caveat is the reCaptcha handling, which is quite harder with a bot/selenium

Process finished with exit code 0
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!