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

180
Views
document.querySelector() return null with selenium

i'm trying to get a textarea in python with selenium. When i go to the browser, i open the console and i send this :

document.querySelector('[id^="h-captcha-response-"]')

I get my textarea, it's perfect.

textarea id="h-captcha-response-0l5458ke7qc" name="h-captcha-response" style="display: none;">

And when i do this command in python with selenium and i want to fill the .innerHTML like :

driver.execute_script(f'''                                                                                                                                                             
document.querySelector('[id^="h-captcha-response-"]').innerHTML = "{code}"                                                                                                             
''') 

It's say :

selenium.JavascriptException: javascript error: Cannot set properties of null (setting 'innerHTML')

Why do I get this error ? On my browser's console I can select the textarea without any problem so why my textarea is null now ?

Thank you for your answer

Joss

about 4 years ago · Juan Pablo Isaza
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!