How to Handle Frames in Selenium WebDriver
H Y R Tutorials
@hyrtutorialsAbout
Welcome to my channel H Y R Tutorials. If you are looking for learning something useful (related to automation testing) with some good explanation, then you are in the right place. In this channel I'm going to share the knowledge on various programming languages, technologies and tools, so please stay tuned to this. π YouTube - https://www.youtube.com/hyrtutorials π Website - https://www.hyrtutorials.com π Facebook - https://www.facebook.com/hyrtutorials π Twitter - https://twitter.com/hyrtutorials π Instagram - https://www.instagram.com/hyrtutorials π Telegram - https://t.me/hyrtutorials π LinkedIn - https://www.linkedin.com/company/hyrtutorials Kindly share this channel and website with your friends and help them as well. π Please Subscribeπ to start learning for FREE now, Also help your friends in learning the best by suggesting this channel.
Latest Posts
Video Description
In this video, I have shown how we can handle Frames in Selenium WebDriver. Frames are a now deprecated means of building a site layout from multiple documents on the same domain. You are unlikely 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 offers 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. Here the index starts from 0(zero) Example: // Switches to the second frame driver.switchTo().frame(1); ------------ Using a name or ID ------------------ If your frame or iframe has an id or name attribute, this can be used instead. If the name or ID is not unique on the page, then the first one found will be switched to. Example: //Using the ID driver.switchTo().frame("testframe"); //Or using the name instead driver.switchTo().frame("frm1"); //Now we can click the button driver.findElement(By.tagName("button")).click(); ------------ 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 iframe = driver.findElement(By.xpath("//h1[.='Frame1']/following-sibling::iframe")); //Switch to the frame driver.switchTo().frame(iframe); //Now we can click the button driver.findElement(By.tagName("button")).click(); --------------- Leaving a frame ------------------------ To leave an iframe or frameset, switch back to the default content like so: Example: // Return to the top level driver.switchTo().defaultContent(); ---------------- Going to parent frame ------------------ When you are in nested frames and you want to come back to the parent frame of all the child frames then we use a method called parentframe. Example: driver.switchTo().frame("testframe1"); driver.switchTo().frame("testChildFrame1"); driver.switchTo().frame("testChildFrame11"); //Return to parent frame driver.switchTo.parentFrame(); ============================================== ************** Checkout my other playlists ************** ============================================== Java Programming videos playlist:π π https://bit.ly/3keRJGa Selenium WebDriver with Java videos playlist:π π https://bit.ly/2FyKvxj Selenium interview questions videos playlist:π π https://bit.ly/3matUB3 Windows automation with FlaUI videos playlist:π π https://bit.ly/33CG4dB CSS Selectors videos playlist:π π https://bit.ly/2Rn0IbD XPath videos playlist:π π https://bit.ly/2RlLdkw Javascript Executor videos playlist:π π https://bit.ly/2FhNXwS Apache POI videos playlist:π π https://bit.ly/2RrngrH Maven videos playlist:π π https://bit.ly/2DYfYZE How to fix Eclipse errors:π π https://bit.ly/3ipvNYf ============================================== ============================================== Connect us @ π Website - www.hyrtutorials.com π Facebook - www.facebook.com/HYRTutorials π LinkedIn - www.linkedin.com/company/hyrtutorials π Twitter - www.twitter.com/Hyrtutorials ============================================== ============================================== π Please Subscribeπ to start learning for FREE now, Also help your friends in learning the best by suggesting this channel. #webAutomation #selenium #frames #hyrtutorials
Build Your Own Greenhouse
AI-recommended products based on this video

LEGO Creator 3 in 1 Retro Roller Skate Building Kit, Transforms from Roller Skate Toy to Mini Skateboard to Boom Box Radio, Birthday Gift for Skaters, Cool Toy for Boys and Girls Ages 8 and Up, 31148

Soleilwear Mini Electric Screwdriver Set, 52 in 1 Precision Electric Screwdriver Cordless with 48 Magnetic Bits, Repair Tool Kit with Tweezers and Pry Bar

Hydroponics Growing System Indoor Garden - Herb Garden with Grow Light, 15 Pods Stainless Steel Indoor Garden Kit, Auto Timer, Gardening Gift for All Ages

Large Hydroponics Growing System 14 Pods, Indoor Herb Garden with LED Grow Light, 5L Water Tank, Hydroponic Grow Kit with 3 Auto-Timers, Rotatable Light Panel and Child Lock for Home School Gardening

Growell Large Hydroponics Growing System Kit, 90 Pods Vertical Hydroponic Garden with 2 Light Modes Grow Light, Auto Circulating Water System, 40L Indoor Gardening System for Herb Vegetable Fruit

iDOO WiFi 12 Pods Hydroponic Growing System with 6.5L Water Tank, Smart Hydro Indoor Herb Garden Up to 14.5", Plants Germination Kit with Pump System, Fan, Grow Light for Home Kitchen Gardening, Black

AeroGarden Harvest Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Black

AeroGarden Harvest Elite 360 Indoor Garden Hydroponic System with LED Grow Light and Herb Kit, Holds up to 6 Pods, Stainless

eSuperegrow Hydroponics Growing System,Smart Hydroponic Gardening System with LED Grow Light,Indoor Garden Hydroponic Herb Grow Kit with Climbing Trellis for Short Tomato,Basil,Pepper,Cucumber

iDOO WiFi 12 Pods Hydroponic Growing System with 6.5L Water Tank, Smart Hydro Indoor Herb Garden Up to 14.5", Plants Germination Kit with Pump System, Fan, Grow Light for Home Kitchen Gardening, Black

AISITIN 1W Solar Fountain 2025 Upgraded, Water Fountain Outdoor with 8 Nozzles Set & 4 Fixed Pipes, Solar Powered Water Fountain Pump for Outdoor Garden, Pond, Pool, and Bird Bath

AISITIN Solar Fountain Pump 2025 Upgraded, 1.5W Solar Powered Water Fountain Pump with 8 Nozzles Set & 4 Fixed Pipes, for Outdoor Garden, Bird Bath, Pond Pool or Fish Tank

10 Herb Garden Planter Indoor Kit, 44pcs Complete Kitchen Herb Starter Set Including Burlap Pots, Markers, Soil Discs, Gardening Tools, Unique Easter/Birthday/Christmas Gift Ideas for Women, Mom

Herb Garden Planter Indoor Kit 21Pcs Kitchen Herb Starter Set Herb Growing Kit Including Wooden Box, Burlap Pots, Soil Discs, Gardening Tools, Unique Easter Birthday Christmas Gift Ideas for Women Mom

Miracle-Gro Seed Starting Potting Mix 8.8L, 2-Pack | Fast Root Development for Seeds & Cuttings | Feeds Instantly for Quick Growth



















