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,210 points
465 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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,050 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,400 points
1,653 views
0 votes
1 answer
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,590 points
390 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,390 views
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,050 points
134 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,130 points
521 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,130 points
124 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
5,222 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,050 points
670 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.