Import Sys
From time import sleep
From selenium import Webdriver
From selenium.webdriver.common.by Import by
From Selenium.webdriver.support.select Import Select
Driver = Webdriver. Ie ()
Driver.find_element_by_css_selector ("Div.yj-icon-box>a:nth-child (5) >i"). Click () #进入主页面
Sleep (1)
Driver.switch_to.frame (' IFRAME0 ')
Sleep (1)
Modify_frame_loc = (By.css_selector, "Div.layui-layer-content>iframe")
AA = Driver.find_element (*modify_frame_loc)
Driver.switch_to.frame (AA)
Sleep (1)
Driver.find_element_by_css_selector ("Div.>i"). Click () #点击iframe0 element
Sleep (1)
Driver.quit ()
The red code is the error code, the cause of the error is the current IFRAME is the most internal iframe, error code clicked on the element in the IFRAME0 layer, the code will be an error message that the element cannot be found.
The correct code is
Driver.switch_to.default_content ()
Driver.switch_to.frame (' IFRAME0 ')
Driver.find_element_by_css_selector ("Div.>i"). Click () #点击iframe0 element
First record encouragement
Common errors in Python automation scripts based on the Selenium module (i)