An i Frame is an associate with hypertext mark-up language document embedded within the present hypertext mark-up language document on a website. i Frame hypertext mark-up language part is employed to insert content from another supply, like a commercial, into an internet page. Internet designers will modification the i Frame's content while not creating them reloads the entire website. A website will have multiple frames on one page. And a frame can even have inner frames. shall we start discussion about Handling I Frames in Selenium WebDriver
I Frame could be a web content that is embedded in associate degree other web content or a hypertext mark-up language document embedded within another hypertext mark-up language document.
Learn more about this technology Selenium Online Training in this overview.
I Frame stands for Inline Frame is hypertext mark-up language document that's enclosed in another hypertext mark-up language document and is employed to put the contents from another. Almost all website includes I Frame now every day, wherever they need to be displaying an advertisement to be taking a part in videos of alternative sources.
i Frames, we have other ways of handling a frame
Select a frame by its zero-based index. That is, if a page has multiple frames the primary frame would be at index “0”, the second at index “1” soon. Once the frame is chosen or navigated, all calls on the web driver interface into a i frame it focus by currently on the frame whatever operations we have a tendency we have a tendency to attempt to perform on pages won’t work and throws part not found as we have a tendency to navigated and switched to border.
Select a frame by its name or ID. Frames placed by matching name attribute square measure continuously given precedence over those matched by ID.
Select a frame and it is placed in a web element and can't notice the frames by simply seeing the page by inspecting a firebug. We cannot notice the frames by simply seeing the page or by inspecting firebug.
By observing Right click on the page and click on 'View Page Source' and Search with the 'i frame', if you'll be able to realize associate degree tag name with the 'frame' then it's intending a page consisting an frame.
We will use this to be told i Frame handling logic. Before beginning we've to know that to figure with totally different i Frames on a page we've to modify between these i Frames. To modify between i Frames we've to use the driver’s switch To().frame command.
We will use the switchTo().frame() in 3 ways:
switchTo.frame(int frameNumber): Pass the frame index and driver can switch to its frame.switchTo.frame(string frameNameOrId): Pass the frame part Name or ID and a driver can switch to it a frame.
switchTo.frame(WebElement frameElement): Pass the frame net part and driver can switch to its frame.
Index of i Frame is that the position at that it happens within the hypertext mark-up language page. Within the higher than example we've found a total variety of i Frames. Within the sample page, we have 2 I Frames, index of i Frame starts from zero. Thus there are 2 i Frames on the page with index zero and one. Index zero is going to be the i Frame that exists.Multiple i frames for a webpage:
Switch to frames by Index:
Index of an i Frame is that the position at that it happens within the markup language page. Within the higher than example we've found the total variety of i Frames. Within the sample page, we have 2 I Frames, index of i Frame starts from zero. Thus there square measure 2 i Frames on the page with index zero and one. Index zero is the i Frame that exists.
Switch to frames by Name:
Now if you are taking a glance at the HTML code of i Frame you will notice that it is named attribute. Name attribute incorporates a price i frame. We will switch to the i Frame the name by mistreatment the command driver.switchTo().frame.
Switch to border ID:
Similar to the name attribute within the i Frame tag we tend to even have the ID attributes. We will use that additionally to change to the frame. All we have to try and do is pass the id to the switch To command like this driver.switchTo().
Get in touch with Online IT Guru for mastering the Selenium Training
Recommended Audience:Software developersETL developersProject ManagersTeam Lead’s
Prerequisites for Learn Selenium. It’s good to have knowledge of basic Concepts like HTML and core Java But it is not mandatory. Trainers of Online IT Guru will teach you if you don’t have knowledge of those Concepts.