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,320 points
3,090 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,500 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
16,016 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
• 28,140 points
22,298 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
6,892 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,150 points
12,363 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,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

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

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 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,910 points
7,221 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 3, 2020 in Selenium by Sri
• 3,190 points
7,874 views
0 votes
6 answers

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

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

answered Feb 13, 2019 in Selenium by anonymous
96,178 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 27, 2018 in Selenium by nsv999
• 5,500 points
8,064 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP