14 Testing Page with iFrames
Automate the controls in frames and inline frames
Learning Objectives
Add a new test script file to an existing project (not by cloning)
start with a web page on a different site
Identify frame
Drive controls in a frame
Back to main content exiting a frame
Test Case 14
Site URL: https://portal.specialisterne.com.au/candidateportal
Tasks
Task 1. Add a new test script
Right-click the “spec” folder and select “New Test Script File”.
Enter a test script file name, in the example, `portal_login_spec.rb
`
Click the “OK” button.
A new file `portal_login_spec.rb
` will be created with the above content (skeleton script filled by TestWise.
Besides the usual update to “Test Group Name” and “Test Case Name”, we need to change the target web page: replace `site_url
` with the specific page URL.
Run the test case (empty at the moment) to verify it opens the target web page OK.
Task 2. Implement the first test step: enter email address
We have done this (entering text in a text box) a few times already. Right-click and inspect it first.
The statement below shall work.
driver.find_element(:name, "username").send_keys("bob@testwisely.com")
But it did not.
Click the “Test Output” tab, and see “Selenium::WebDriver::Error::NoSuchElementError”. Why?
Knowledge Point: Frame and iFrame
If we scroll up the page source in the inspect panel. We can another `<HTML>
` tag under `<iframe>
` tag.
<iframe>
tag specifies an inline frame. You can think a frame is an independent web page but is included in another one.
Using frame is discouaraged. However, inline frames are still heavily used in enterprise web sites, such as Microsoft SharePoint/Dynamic 365 and WordPress. This test site is Zoho Recruit, another popular site.
From my memory, over 50% client web apps (including in recent years) 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 so-called 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)
Task 3. Drive controls in a frame
In the context of Test Automation, frame and inline frame are treated the same.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.