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,280 points
1,008 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,430 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,440 points
4,170 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 in Selenium by Abha
• 27,200 points
1,523 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,650 points
934 views
0 votes
1 answer
0 votes
1 answer

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,430 points
1,193 views
0 votes
1 answer
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,510 points
1,278 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,510 points
1,036 views
0 votes
3 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 in Selenium by anonymous
12,923 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,430 points
1,368 views