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