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

766
Views
Selenium python buscar y reemplazar texto

Estoy tratando de reemplazar el texto dentro de una cadena en el backend de Wagtail usando Selenium y Python. Mi estrategia es:

  • Encuentra el elemento que contiene el texto con contains(text()
  • Reemplace la cadena que necesito reemplazar (en este caso, algún precio)
  • sustituir el texto antiguo por el nuevo

 element = driver.find_element(By.XPATH,"//*[contains(text(), '17,30')]") newprice= str(element.text).replace('17,30',"1000") driver.execute_script("arguments[0].innerText = ",newprice, element)
Este es el mensaje de error que recibo.

selenium.common.exceptions.JavascriptException: Mensaje: error de javascript: identificador inesperado

El siguiente código funciona pero no hace lo que necesito. El elemento que contiene "17,30" también contiene otro texto. Con el siguiente código, todo el texto será sustituido por "1000".

 element = driver.find_element(By.XPATH,"//*[contains(text(), '17,30')]") driver.execute_script("arguments[0].innerText = '1000'", element)

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!