In this video, I have explained about how we can handle Frames in Selenium WebDriver.
Frames are a now deprecated. You might not get chance to work with them unless you are working with a pre-HTML5 web app. Iframes allow the insertion of a document from an entirely different domain and are still commonly used.
To interact with any control inside the frame, we will need to first switch to the frame, in a similar way to how we switch windows. WebDriver has three ways of switching to a frame.
1) Using an index
2) Using a name or ID
3) Using a WebElement
***** Using an index *****
It is possible to use the index of the frame to switch to that frame, such as can be queried using window.frames in JavaScript.
The first frame on the webpage has index 0.
Example:
//Switch to the first frame
driver.switchTo().frame(0);
***** Using a name or id *****
If webpage frame has id or name inside html. Then the name or ID can be user to identify frame and switched to.
Example:
//Using id or name
driver.switchTo().frame("frame1");
***** Using a WebElement *****
Switching using a WebElement is the most flexible option. You can find the frame using your preferred selector and switch to it.
Example:
//Store the web element
WebElement frame = driver.findElement(By.id("frame1"));
driver.switchTo().frame(frame);
On this page of the site you can watch the video online How to Handle Frames in Selenium WebDriver | Selenium - Java with a duration of hours minute second in good quality, which was uploaded by the user CodeWithAvadoot 13 March 2021, share the link with friends and acquaintances, this video has already been watched 220 times on youtube and it was liked by 11 viewers. Enjoy your viewing!