Java Selenium (14) Handling elements in an IFRAME

Source: Internet
Author: User

What is an IFRAME

An IFRAME is an HTML that is used for Web page nesting. A Web page can be nested in another Web page and can nest many layers.

A method for entering an IFRAME is provided in the selenium

Enter the ID called Framea of Iframedr.switchto (). FRAME ("Framea");
Back to main window Dr.switchto (). Defaultcontent ();

Main.html

Frame.html

Selenium code

    public static void Testiframe (Webdriver driver)    {        driver.get ("E:\\stashfolder\\[email protected]\\stash\\ tank-moneyproject\\ Pudong Software Park Training center \ \ My textbook \\Selenium webdriver\\frame\\main.html ");                    In the main window        driver.findelement (by.id ("Maininput")). SendKeys ("main input");        Without entering the IFRAME at this time, the following statement will error        //driver.findelement (by.id ("Iframeinput")). SendKeys ("iframe input");                        Driver.switchto (). FRAME ("Framea");        Driver.findelement (By.id ("Iframeinput")). SendKeys ("iframe input");                At this time there is no main window, the following statement will error        //driver.findelement (by.id ("Maininput")). SendKeys ("main input");                Back to main window        Driver.switchto (). Defaultcontent ();        Driver.findelement (By.id ("Maininput")). SendKeys ("main input");      }

Java Selenium (14) Handling elements in an IFRAME

Related Article

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.