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

171
Views
python selemium driver.execute_script()

I want to cancel all checkbox one time. Use element.click() is ugly but it can work like this

allcan=driver.find_elements(By.XPATH,'//*[@type="checkbox"]')
for i in allcan:
    i.click()

So I try to use driver.execute_script() like this

allcan = 'var index = form1.no.value; \
            for (i=1;i<=index;i++){ \
                var rchk = document.getElementsByName("del_Y"+i)[0] \
                rchk.checked = false \
                ;}'
driver.execute_script(allcan) 

That JavaScript can work in chrome console,but in python it show me

JavascriptException: Message: javascript error: Unexpected identifier
(Session info: chrome=99.0.4844.82)

I don't know why please help me.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to end this statement with semicolon.

var rchk = document.getElementsByName("del_Y"+i)[0];

This will get rid of SyntaxError, but as @Peterrabbit mentioned in the comment you need to pay attension to i and form1 as those variables are not defined. So most likely you will encounter with Reference Error.

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!