Need to switch between frames in Selenium

0 votes
I have a WebDriver code and need to switch between two frames. I recorded the testcase using selenium IDE and when expored the Java code, I got the values as
selectFrame relative=top select Frame=middle Frame

But the problem is, its not able to recognize relative=top and middleFrame. How to solve this error in WebDriver. I'm using Java?
Apr 6, 2018 in Selenium by Martin
• 4,340 points
1,833 views

1 answer to this question.

0 votes

For switching between frames, use driver.switchTo().frame(). First locate the frame id and define it in a WebElement. Ex:- 

WebElement fr = driver.findElementById("id");

Then switch to this frame using this code:- 

driver.switchTo().frame("Frame_ID");

This is how it should fially look like:

WebElement fr = driver.findElementById("theIframe");
driver.switchTo().frame(fr);

Then to move to default frame, use:- 

driver.switchTo().defaultContent();
answered Apr 6, 2018 by nsv999
• 5,520 points

Related Questions In Selenium

0 votes
1 answer

How to switch between two windows in browser using Selenium java

Yes, this is possible. First, you need ...READ MORE

answered Sep 25, 2018 in Selenium by Meci Matt
• 9,460 points
10,081 views
0 votes
1 answer

How to open new tab in same browser and switch between them using Selenium?

Hi Mugdha, you can use following code ...READ MORE

answered May 24, 2019 in Selenium by Abha
• 27,950 points
11,596 views
0 votes
1 answer

Need to know the differences between .// and //* in XPath?

The expressions your talking about, select different ...READ MORE

answered Apr 29, 2018 in Selenium by king_kenny
• 3,710 points
2,584 views
0 votes
1 answer

How to switch back from a frame to default in Selenium Webdriver?

Hey Rupesh, to switch back from a ...READ MORE

answered Jun 25, 2019 in Selenium by Anvi
• 14,110 points
6,096 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,520 points
4,028 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31 in Selenium by Sri
• 2,970 points
4,976 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,890 points
2,917 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 2 in Selenium by Sri
• 2,970 points
3,349 views
0 votes
4 answers

How to specify "ENTER" button functionality in Selenium WebDriver code?

using OpenQA.Selenium.Interactions; Actions builder = new Actions(driver); ...READ MORE

answered Feb 12, 2019 in Selenium by anonymous
46,877 views
0 votes
1 answer

Selenium ChromeDriver issue - Want to run it in background, but not as headless browser

This is a flaw with ChromeDriver. Tried ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,520 points
3,963 views