- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to wait for iFrames to load completely in Selenium webdriver?
We can wait for the iframe to load completely with Selenium webdriver.First of all we need to identify the iframe with the help iframe id, name, number or webelement. Then we shall use the explicit wait concept in synchronization to wait for the iframe to load.
We need to import org.openqa.selenium.support.ui.ExpectedConditions and import org.openqa.selenium.support.ui.WebDriverWait to incorporate expected conditions and WebDriverWait class. We will wait for the iframe to be loaded with the condition frameToBeAvailableAndSwitchToIt.
Let us see an html document of a frame.
Example
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.ExpectedConditions; public class FrameLoadWait{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver","C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); driver.get("https://the-internet.herokuapp.com/nested_frames"); // frame load explicit condition WebDriverWait w = new WebDriverWait(driver, 5); w.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt("frame-bottom")); // identify element inside frame WebElement p=driver.findElement(By.cssSelector("body")); System.out.println("Text inside frame is: " + p.getText()); driver.close(); } }
Output
- Related Articles
- Need to wait until page is completely loaded - Selenium WebDriver
- Wait for complex page with JavaScript to load using Selenium.
- How do you make Selenium 2.0 wait for the page to load?
- Best practice to wait for a change with Selenium Webdriver?
- Wait for an Ajax call to complete with Selenium 2 WebDriver.
- How to save and load cookies using Python Selenium WebDriver?
- Wait until page is loaded with Selenium WebDriver for Python.
- How to set Page Load Timeout using C# using Selenium WebDriver?
- How to get Selenium to wait for ajax response?
- How to know the exact time to load a page using Selenium WebDriver?
- How to use Selenium WebDriver for Web Automation?
- How to wait for options in a select to be populated in Selenium?
- How to check URL for 404 using Selenium WebDriver?
- How to automate Calendar using Selenium WebDriver for Testing?
- Is there any way to load an extension in chrome browser using Selenium Webdriver?

Advertisements