IFrame Handling

Web Elements & Operations on the Web Elements, Selenium Element Locators, Selenium WebDriver API Commands, Writing Test Steps, Inserting Verification Points, Inserting Comments and exception Handling.
Post Reply
ramya
Posts: 89
Joined: Fri Nov 23, 2018 2:55 am

IFrame Handling

Post by ramya » Sat Nov 24, 2018 4:55 am

How to handle the IFrames In selenium ?

manoj
Posts: 87
Joined: Fri Nov 23, 2018 5:29 am

Re: IFrame Handling

Post by manoj » Sat Nov 24, 2018 4:57 am

// Click on link to open iFrame
driver.findElement(By.id("iFrame_Name")).click();

// Switch to Frame
driver.switchTo().frame("iframe");

// Perform operation on Frame
driver.findElement(By.id("tinymce")).sendKeys("Send text in iframe");

// Switch back to defaultContent
driver.switchTo().defaultContent();

// Switch between one frame to another
driver.switchTo().frame("iframe_1").switchTo().frame("iframe_2");

srini
Posts: 76
Joined: Thu Jan 03, 2019 3:58 am

Re: IFrame Handling

Post by srini » Fri Jan 04, 2019 5:02 am

To Switch between iFrames we have to use the driver’s switchTo().frame command.

We can use the switchTo().frame() in three ways:
===================================
1.switchTo.frame(int frameNumber): Pass the frame index and driver will switch to that frame.
2.switchTo.frame(string frameNameOrId): Pass the frame element Name or ID and driver will switch to that frame.
3.switchTo.frame(WebElement frameElement): Pass the frame web element and driver will switch to that frame.

sekhar
Posts: 42
Joined: Mon Dec 31, 2018 6:40 am

Re: IFrame Handling

Post by sekhar » Sat Jan 05, 2019 11:02 am

What is the difference between Frame and iFrame?

Post Reply

Return to “Writing Selenium Test Cases”