Selenium can't locate the element? It may be an element in the iframe tag

Selenium ui automation script, directly use xpath to locate a tag after login and find that it cannot be located

insert image description here

So I looked at the html structure again and found that there are two layers of iframe outside the a tag

insert image description here
So you need to enter the iframe layer by layer, and you can find the element normally by using xpath positioning, driver.switch_to.frame(), you can write the name of the iframe tag in ()

driver.switch_to.frame('ipanel')
driver.switch_to.frame('menu')
driver.find_element(By.XPATH,'//*[@id="m06"]').click()

insert image description here

Guess you like

Origin blog.csdn.net/z12347891/article/details/129369530