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

486
Views
El objeto WebDriver' no tiene atributo 'switch_to_frame'

No puedo cambiar a los iFrame identificados correctamente. El script identifica el iFrame (marcado en el depurador), pero el cambio al iFrame falla y se ejecuta en la trampa de excepción. Hace un par de veces funcionaba perfectamente.

 Message='WebDriver' object has no attribute 'switch_to_frame'

¿Qué pasó mientras tanto?

Chromedriver se actualizó de la versión 95.0.4638.17 a ChromeDriver 96.0.4664.45

¿El Chromedriver ya no es compatible con la última versión de Selenium?

 ... driver.switch_to.default_content() try: # find the frame wait.until(EC.element_to_be_clickable((By.ID, "wysiwygTextarea_ifr"))) frame2 = driver.find_element(By.XPATH, "//iframe[@id='wysiwygTextarea_ifr']"); # switch to frame driver.switch_to.frame(frame2.tag_name); print("--------------iframe found-------------------"); except: print("--------------iframe not found-------------------"); ...
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Al cambiar a frame , las notaciones admitidas son:

  • Cambie a un marco usando el nombre del marco :

     driver.switch_to.frame('frame_name')
  • Cambie a un marco usando el índice de marco :

     driver.switch_to.frame(1)
  • Cambie a un marco usando el elemento de marco :

     driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0])
    • Cambiar al marco principal:

      driver.switch_to.parent_frame()

  • Cambiar al contenido predeterminado :

     driver.switch_to.default_content()

este caso de uso

Para cambiar el marco que ha utilizado:

 driver.switch_to.frame(frame2.tag_name);

es decir, el TAG_NAME que no es compatible. Por lo tanto usted ve el error:

 Message='WebDriver' object has no attribute 'switch_to_frame'

Solución

Puede utilizar la siguiente línea de código:

 # find the frame wait.until(EC.element_to_be_clickable((By.ID, "wysiwygTextarea_ifr"))) frame2 = driver.find_element(By.XPATH, "//iframe[@id='wysiwygTextarea_ifr']"); # switch to frame by frame element driver.switch_to.frame(frame2);
over 4 years ago · Santiago Trujillo 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!