Switching directly to parent frame using parentFrame()

Selenium 4: New Features Selenium 4 - New Featues
14 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€47.98
List Price:  €67.18
You save:  €19.19
£39.89
List Price:  £55.85
You save:  £15.96
CA$70.14
List Price:  CA$98.21
You save:  CA$28.06
A$76.87
List Price:  A$107.62
You save:  A$30.75
S$67.31
List Price:  S$94.24
You save:  S$26.93
HK$389.14
List Price:  HK$544.83
You save:  HK$155.68
CHF 44.67
List Price:  CHF 62.54
You save:  CHF 17.87
NOK kr553.51
List Price:  NOK kr774.97
You save:  NOK kr221.45
DKK kr357.84
List Price:  DKK kr501
You save:  DKK kr143.16
NZ$85.68
List Price:  NZ$119.95
You save:  NZ$34.27
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.46
৳5,972.22
List Price:  ৳8,361.58
You save:  ৳2,389.36
₹4,221.07
List Price:  ₹5,909.84
You save:  ₹1,688.76
RM223.35
List Price:  RM312.71
You save:  RM89.36
₦84,627.22
List Price:  ₦118,484.88
You save:  ₦33,857.66
₨13,887.22
List Price:  ₨19,443.22
You save:  ₨5,556
฿1,722.96
List Price:  ฿2,412.28
You save:  ฿689.32
₺1,727.27
List Price:  ₺2,418.32
You save:  ₺691.05
B$289.99
List Price:  B$406.01
You save:  B$116.02
R907.60
List Price:  R1,270.71
You save:  R363.11
Лв93.82
List Price:  Лв131.35
You save:  Лв37.53
₩70,211.45
List Price:  ₩98,301.65
You save:  ₩28,090.20
₪185.71
List Price:  ₪260.01
You save:  ₪74.30
₱2,946.36
List Price:  ₱4,125.14
You save:  ₱1,178.78
¥7,736.95
List Price:  ¥10,832.35
You save:  ¥3,095.40
MX$1,021.22
List Price:  MX$1,429.79
You save:  MX$408.57
QR182.26
List Price:  QR255.18
You save:  QR72.92
P683.46
List Price:  P956.90
You save:  P273.44
KSh6,472.14
List Price:  KSh9,061.51
You save:  KSh2,589.37
E£2,482.01
List Price:  E£3,475.01
You save:  E£993
ብር6,118.22
List Price:  ብር8,566
You save:  ብር2,447.77
Kz45,640.87
List Price:  Kz63,900.87
You save:  Kz18,260
CLP$48,886.48
List Price:  CLP$68,444.99
You save:  CLP$19,558.50
CN¥362.07
List Price:  CN¥506.93
You save:  CN¥144.86
RD$3,012.01
List Price:  RD$4,217.06
You save:  RD$1,205.04
DA6,712.40
List Price:  DA9,397.90
You save:  DA2,685.50
FJ$113.77
List Price:  FJ$159.29
You save:  FJ$45.51
Q385.78
List Price:  Q540.13
You save:  Q154.34
GY$10,455.70
List Price:  GY$14,638.82
You save:  GY$4,183.11
ISK kr6,980.70
List Price:  ISK kr9,773.54
You save:  ISK kr2,792.83
DH502.76
List Price:  DH703.91
You save:  DH201.14
L910.90
List Price:  L1,275.33
You save:  L364.43
ден2,951.80
List Price:  ден4,132.76
You save:  ден1,180.95
MOP$400.70
List Price:  MOP$561.01
You save:  MOP$160.31
N$906.31
List Price:  N$1,268.91
You save:  N$362.60
C$1,838.97
List Price:  C$2,574.70
You save:  C$735.73
रु6,749.45
List Price:  रु9,449.77
You save:  रु2,700.32
S/189.51
List Price:  S/265.32
You save:  S/75.81
K201.21
List Price:  K281.71
You save:  K80.50
SAR187.68
List Price:  SAR262.77
You save:  SAR75.08
ZK1,382
List Price:  ZK1,934.92
You save:  ZK552.91
L238.86
List Price:  L334.42
You save:  L95.56
Kč1,216.06
List Price:  Kč1,702.59
You save:  Kč486.52
Ft19,746.05
List Price:  Ft27,646.05
You save:  Ft7,900
SEK kr551.69
List Price:  SEK kr772.42
You save:  SEK kr220.72
ARS$50,176.71
List Price:  ARS$70,251.41
You save:  ARS$20,074.70
Bs345.34
List Price:  Bs483.50
You save:  Bs138.16
COP$219,443.60
List Price:  COP$307,238.59
You save:  COP$87,794.99
₡25,456.77
List Price:  ₡35,641.51
You save:  ₡10,184.74
L1,262.95
List Price:  L1,768.23
You save:  L505.28
₲390,155.46
List Price:  ₲546,248.87
You save:  ₲156,093.40
$U2,130.69
List Price:  $U2,983.14
You save:  $U852.45
zł208.13
List Price:  zł291.40
You save:  zł83.27
Already have an account? Log In

Transcript

Hello everyone, in this video session I am going to explain part 14 of selenium four that is switching directly to parent from using parent friend command or method in Selenium four. So till Selenium three the scenario used to be like this. Okay, so let's say this is a web page and inside this web page there is a let's say there is a frame inside this webpage let's say there is a frame and inside this frame there is another frame which is a child frame of this parent frame Okay, there is another frame. So, let me write down is a webpage and default page. Then this is a parent frame, parent iframe this and this is a child frame. Frame inside another frame, okay, an iframe inside another frame which is a child remove this parent frame.

Okay, let me Write it again parent sorry this is a page and this is a parent okay parent frame and this is the child frame right. Now this how to switch to outcome to this child frame not to come to this child friend we have to start from the page okay once we are on this page once the page is loaded from the web page we have to switch to the parent frame first okay we cannot directly go to the child frame right from parent from this page we cannot directly this is not possible okay directly from here here to here is not possible. So, what we have do we are first switched to the parent frame after searching for the parent frame we have to switch to the child Okay. Then if I want to switch back to the child frame from child frame to the parent frame, we want to switch back from the child frame to the parent frame.

Is this possible in Selenium three, it is not possible. Okay. In Selenium three, this is not possible. Directly switching from the child friend back to the parent frame is not possible then what is the process of switching to the parent frame from chancing? So, after you switch the child frame if you want to go to the parent frame, the only process was to first switch to the page directly default page default content you have to switch then you have to again come to the parent frame. This is only possible in the Selenium triggers okay.

You cannot directly go from child to the parent frame you have to first go to the default and then come from there to the parent frame. But in Selenium for the introduce a new method is that is the name of this method is parent frame method. Okay, the main method is parents and there's a parent frame method. So what is the difference here? The same scenario desert pitch and this is a Parent frame and let's say this is a child frame. So, this is a parent parent window This is the page sorry parent will then say this is a default webpage okay default page you can say and this is a parent frame and this is a soil frame okay child.

For example if you want us go to this child frame you synonym for also you have to first go to the parent frame and after switching to the parent frame how to switch to the child from like this. Okay. Again from child from if you want to switch back to the parent frame, you can directly switch to the parent frame this using this method known as this parent frame method. Okay using this parent frame method you can switch back directly to the parent frame. This is This option is not available in Selenium trigger if it's newly introduced in Selenium four wire is one of the new features of selenium four way you can Directly switch from the child form to the parent frame. Okay, you don't have to you don't have to like okay go to the default page and come back to the parent from that is not required Yes, since because of this method you can directly switch from child from the parent okay.

So, let me practically demonstrate Okay, this particular parent frame method you for that let me open the eclipse ID. So, so far these are the different demonstrations I did let me create a new class I said demo well, and public static Weidman finish created inside the main method and just write down the basic steps like WebDriver driver is equal to new chrome driver. Okay. import this bar this is the basic steps So before this I will say that I add this WebDriver manager. driver manager dot chrome driver manager dot chromedriver dot setup. Okay, Sparky so driver dot manage dot window dot maximize for maximizing the browser window and then driver.manage.py What's happening?

Okay is going on timeout start implicitly wait okay then time unit dot seconds these are the basic steps. For every test you read these things okay to make your test run smoothly. Then guys we have opened this application We have an example application guys. https colon double slash www.uc. Katie crackage.com slash HTML slash tags, slash HTML underscore iframe underscore tag dot CFM. Okay, this URL you have to take, and this has some parent and child iframes case, okay, that's why I'm taking this example.

I want to get so in other websites, we cannot get this parent and child iframe. So very less websites out there on the web, which have this parent and child license. Okay. So let me visually show you what is a parent and a child iframe first. So here open this application that I was talking about. And after you go to this application, you scroll down a bit.

As you can see, there is a box here, right? So this is a frame and inside this is another frame, okay. In fact, this is a parent iframe. Okay. And inside this parent type frame. Somewhere around inside this parent iframe, we have another iframe.

Okay, this is a child iframe. And this is the parent, iframe, parent and child. If you scroll down a bit, see, parent iframe means complete. This white box is getting located. And inside the white box, another box is there. If you hover this the inside box that is our inside iframe is reading.

This is a child iframe this Okay, whatever I'm highlighting now is a child a friend. This is a parent iframe. So now we have the iframes. Ready? So in this application, so Okay, so how to switch to the parent iframe. Okay.

So here you see there are two iframes. One is parent ID inside the child iframe is that first let's switch to the okay. In order to go to this child, I think we have to first start with the parent iframe. Okay. So how to switch to the parent iframe. Simple.

Okay. So inspect this parent iframe first. And this is iframe iframe with SRC is equal to some Texas there okay. So I will create a CSS selector here. Select this and say Ctrl F And I will double click and then copy this text Okay, ending text editor port for this src attribute name, and its value has some editor port for a design. an iframe is a tag that will create an CSS selector for this iframe.

Okay SRC ends with in Swift, sweet, both for enter. Okay, so it's locating the parent iframe. So copy this parent iframe expert first web element. Parent frame is equal to driver dot find element by dot CSS selector and add to provide the CSS selector for locating that parent iframe. Now, after creating this web element for the parent iframe, we can now switch to this parent frame. Okay, parent frame, how to do that driver.is light switching to parent iframe The contract was there on the default web page from the default web page that is default web page is nothing but this entire webpage from this default web page we are going inside this first parent frame okay as parents in the surrounding box.

So, switch to parent iframe first that is driver dot, what is the command a switch to command which is already there in Selenium three? frame. Here we need to select parent frame Okay, whatever the parent frame I created, I will provide this web element here, okay, we need to provide the web element. So it will switch you to the parent frame. Once you switch to the parent frame. Okay, then you can go to the childcare, right this friend.

So how to switch to the child thing for that also. So we have to create a web element for the child's name. So inspect this child frame, and it has some other iframe here. And this iframe SRC is ending with some text like tag underscore example. Yes. Okay.

Copy this. One minute, I will click and then copy this link back tag underscore example dot CSS Okay, copy this now here instead of a typo just do that ending part and you see the child iframe is getting located with this CSS selector. Now using this I'm going to create a web element, web element. And frame is equal to driver dot find element by dot CSS selector Buda child CSS selector and now there is an element of the child frame. Now for as we as we are inside the parent frame, okay, as we are inside the parent frame, this child frame will be visible right directly from default web page this child frame will not be visible based okay? You're not to go to this child frame you have to go from the default web base which to the parent frame and from parent from your to switch to child from this child from is not visible to the default webpage by default.

Okay, so now since we have already inside the parent iframe, we Since the child frame will be visible to the parent iframe let's switch to that okay switching to child iframe driver dot switch to dot frame here give this child development of the child after switching to the child thing Okay, in Selenium three, switching back to the parent frame method is not available okay parent frame method is not available for switching directly from the child from to the parent not to switch to the switch back to the child to the parent we have to first go to the default rate and again come from under a parent. Third is a very lengthy process to work on this they created a shortcut method like parent frame where directly where if you are inside the child frame, you can directly go to the experience from using this method.

Parent frame method is the method. Okay? So let me let's switch back to the to the parents how to switch back to the parent timeframe or ever done Same simple comments which to and there is a newly introduced method known as parent frame which was not there in the Selenium three guy so it is introduced in Selenium four okay. So parents say that So, using this simple parent frame method you can switch from child frame to the parent frame again you are back to that again you are back to the parent frame now, so, how to make sure that you are inside the parent frame so, this child frame is only visible to this parent frame okay if this child frame is visible okay is displayed or something inside this current frame then that means we are inside the parent frame So, for that I am saying is okay if since we are inside of the parent from the child from child to child from a web element will be visible okay this is only web element available here okay as you can see here inside the parent frame there is no UI element okay there is no hitting no text nothing blank okay only the thing is that is available is child frame.

So, I will treat this as a web element, this m data frame as a web element and see that whether this is this web element is available or not. If it is That means we are inside of the parent if this child frame element okay thought is displayed is available or displayed then System dot out dot print dollar inside parent frame I will say okay and then I will say driver dot close to closer closer okay so you don't have to worry much about this program only thing you have to see is that switching back from the child sim to the parent from directly using this parent frame method okay run this it will print inside parents and because we have such wealth from the child's home to the parents in successfully So, let it come here today as you can see inside parents saying so this this is how guys using the parent frame methods we can switch from the child frame Did the parent experiment directly okay which was not possible in Selenium testing itself at a rate that is in the Selenium for Okay, so that's it guys in the next video session I am going to explain how to install an uninstalled add ons using these two methods Okay, which are newly introduced in Selenium four.

So I'm going to explain one of the new features of selenium four as part of the part 15 of this series, where you are you will be able to install and uninstall items using these two methods which are introduced in Selenium four. Okay. So that's it, guys. See you in the next video session. Thank you. Bye

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.