Endtest

Endtest

›Web Tests

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

How to test in iframes

Introduction

An HTML iframe is used to display a web page within a web page

Most modern web applications might use iframes in some sections.

For example, in a Checkout page, the credit card inputs are usually inside an iframe.

Endtest allows you to easily interact with elements from iframes.

Detect if an element is inside an iframe

We can detect if an element is inside an iframe by inspecting the element with the Chrome Developer Tools.

An easier way is to perform a Right Click near the element in your browser and see if View Frame Source option is present in the context dropdown.

Interact with an element that is inside an iframe

Since the iframe is a separate web page, we have to tell the test to switch the focus to that iframe before interacting with an element from inside the iframe.

In the Miscellaneous action, you have the following methods:

  • Switch to iframe
  • Switch back to main

The Switch to iframe method will be used when we need to switch focus to the iframe.

When we are done interacting with the elements from the iframe, we need to use the Switch back to main method to switch the focus back to the main web page.


Dealing with nested iframes

There are situations where you might encounter nested iframes.

An iframe which is inside another iframe is called a nested iframe.

The solution is to switch focus to the first iframe, and then to the next one.

After you're done interacting with the elements from the nested iframe, use one Switch back to main step to return the focus to the main web page.

Dealing with iframes that have dynamic IDs

In some cases, an iframe might have a dynamic ID.

Since a dynamic ID keeps changing, it isn't a reliable locator.

The solution is to write a custom XPath or CSS Selector for that Switch to iframe step.

The Switch to iframe action is using the switch_to method from Selenium WebDriver.

The Switch back to main action is switching to the default_content.

← Web Applications with restricted accessHow to test in multiple tabs →
  • Introduction
  • Detect if an element is inside an iframe
  • Interact with an element that is inside an iframe
  • Dealing with nested iframes
  • Dealing with iframes that have dynamic IDs
© Endtest Inc.