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-------------------"); ...
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()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'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);