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

194
Views
how to run javascript function in selenuim

how i can run this js code in selenuim

window.hcaptcha.render = (container, params) => {
console.log(container)
console.log(params)
window.hcaptchaCallback = params.callback
}
const scriptUrl = new URL(Array.from(document.querySelectorAll('script')).filter(s => s.src.includes('https://js.hcaptcha.com/1/api.js')).map(s => s.src)[0])
window[scriptUrl.searchParams.get('onload')]()

I tried whith driver.execute_script but it doesn't work

  driver.execute_script('window.hcaptcha.render = (container, params) => { window.hcaptchaCallback = params.callback }')
  driver.execute_script("const scriptUrl = new URL(Array.from(document.querySelectorAll('script')).filter(s => s.src.includes('https://hcaptcha.com/1/api.js')).map(s => s.src)[0])")
  driver.execute_script("window[scriptUrl.searchParams.get('onload')]();")
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use python multi-line strings with triple quotes e.g """ .... """ or ''' ... '''

driver.execute_script("""
    window.hcaptcha.render = (container, params) => {
        console.log(container)
        console.log(params)
        window.hcaptchaCallback = params.callback
    }
    const scriptUrl = new URL(Array.from(document.querySelectorAll('script')).filter(s => s.src.includes('https://js.hcaptcha.com/1/api.js')).map(s => s.src)[0])
    window[scriptUrl.searchParams.get('onload')]()
""")
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!