Automated Testing Frames in Selenium WebDriver
A repost of my daughter’s article with permission and slight modification. I added it here for the convenience of my blog subscribers. You can find more Selenium examples like this one in my eBook: Selenium WebDriver Recipes in Ruby. This is also included in my “How to in Selenium WebDriver” series.
Frames are deprecated in HTML5. However, iFrames (inline frames) are still widely used in many web apps, in particular, large enterprise apps such as Microsoft SharePoint and Dynamic 365.
From my memory, over 50% client web apps I worked on used iFrames. So, a few years ago, I was shock to know that so-called popular Cypress did not support Frames, and others. How could a test automation framework/tool be so crippled? Especially, W3C standard-based Selenium WebDriver is so much better. (many people used Selenium WebDriver wrongly, see my other articles for more)
This tutorial will show you multiple ways to test web pages with frames in Selenium WebDriver.
Table of Contents:· iFrames vs Frames — What’s the Difference?
· Steps to Automated Testing page operations in a Frame
· How to Switch to a Frame?
∘ Identify Frame by ‘ID’
∘ Identify a frame by Name does not work
∘ Identify Frame by finding the frame element
∘ Find Frame by Index
· Leave the frame after done
iFrames vs Frames — What’s the Difference?
<frame>) are used in conjunction with Framesets. A frameset splits the view of a browser into sections (frames). And each frame contains an independent page.
<frameset rows="100,*" frameborder="0" border="0" framespacing="0">
<frame name="topNav" id="topNavId" src="top_nav.html">
<frameset cols="200,*" frameborder="0" border="0" framespacing="0">
<frame name="menu" id="menu_frame" src="menu_1.html" scrolling="auto" noresize>
<frame name="content" src="content.html">
iFrames are used to embed a document within the current HTML document (hence ‘inline’ in the name), without being in a frameset. In short, it’s like…