Common errors in Python automation scripts based on the Selenium module (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.