Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda