How to access an iframe using Selenium Python

Asked

Viewed 2,337 times

0

Does anyone know how I can access an iframe from a web page without the iframe ID and NAME ?

I know there’s a command calledswitch_to_frame.

1 answer

1


You can do it this way:

# Pega o XPath do iframe e atribui a uma variável
iframe = driver.find_element_by_xpath("//*[@id="editor"]/div[3]/div[3]/iframe")

# Muda o foco para o iframe
driver.switch_to.frame(iframe)

# Retorna para a janela principal (fora do iframe)
driver.switch_to.default_content()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.