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
€46.61
List Price:  €65.26
You save:  €18.64
£39.96
List Price:  £55.95
You save:  £15.99
CA$68.39
List Price:  CA$95.75
You save:  CA$27.36
A$76.59
List Price:  A$107.23
You save:  A$30.64
S$67.96
List Price:  S$95.15
You save:  S$27.19
HK$391.36
List Price:  HK$547.94
You save:  HK$156.57
CHF 45.64
List Price:  CHF 63.91
You save:  CHF 18.26
NOK kr547.39
List Price:  NOK kr766.40
You save:  NOK kr219
DKK kr347.66
List Price:  DKK kr486.75
You save:  DKK kr139.09
NZ$83.90
List Price:  NZ$117.46
You save:  NZ$33.56
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,478.47
List Price:  ৳7,670.29
You save:  ৳2,191.82
₹4,165.48
List Price:  ₹5,832.01
You save:  ₹1,666.52
RM238.82
List Price:  RM334.37
You save:  RM95.55
₦63,338.32
List Price:  ₦88,678.72
You save:  ₦25,340.40
₨13,897.67
List Price:  ₨19,457.85
You save:  ₨5,560.18
฿1,850.91
List Price:  ฿2,591.43
You save:  ฿740.51
₺1,624.82
List Price:  ₺2,274.88
You save:  ₺650.06
B$257.30
List Price:  B$360.25
You save:  B$102.94
R950.48
List Price:  R1,330.75
You save:  R380.27
Лв91.20
List Price:  Лв127.68
You save:  Лв36.48
₩68,703.94
List Price:  ₩96,191.02
You save:  ₩27,487.07
₪189.75
List Price:  ₪265.67
You save:  ₪75.91
₱2,888.99
List Price:  ₱4,044.82
You save:  ₱1,155.83
¥7,775.71
List Price:  ¥10,886.62
You save:  ¥3,110.91
MX$852.59
List Price:  MX$1,193.70
You save:  MX$341.10
QR182.06
List Price:  QR254.90
You save:  QR72.84
P692.34
List Price:  P969.33
You save:  P276.99
KSh6,723.65
List Price:  KSh9,413.65
You save:  KSh2,690
E£2,394.34
List Price:  E£3,352.26
You save:  E£957.92
ብር2,838.38
List Price:  ብር3,973.96
You save:  ብር1,135.57
Kz41,866.62
List Price:  Kz58,616.62
You save:  Kz16,750
CLP$47,624.47
List Price:  CLP$66,678.07
You save:  CLP$19,053.60
CN¥362.22
List Price:  CN¥507.14
You save:  CN¥144.92
RD$2,935.86
List Price:  RD$4,110.44
You save:  RD$1,174.58
DA6,715.26
List Price:  DA9,401.90
You save:  DA2,686.64
FJ$114.57
List Price:  FJ$160.42
You save:  FJ$45.84
Q388.02
List Price:  Q543.26
You save:  Q155.24
GY$10,449.73
List Price:  GY$14,630.45
You save:  GY$4,180.72
ISK kr6,996.60
List Price:  ISK kr9,795.80
You save:  ISK kr2,799.20
DH506.56
List Price:  DH709.23
You save:  DH202.66
L890.37
List Price:  L1,246.59
You save:  L356.22
ден2,871.51
List Price:  ден4,020.35
You save:  ден1,148.83
MOP$402.79
List Price:  MOP$563.94
You save:  MOP$161.15
N$957.24
List Price:  N$1,340.22
You save:  N$382.97
C$1,837.34
List Price:  C$2,572.43
You save:  C$735.08
रु6,654.43
List Price:  रु9,316.74
You save:  रु2,662.30
S/185.19
List Price:  S/259.29
You save:  S/74.09
K189.75
List Price:  K265.67
You save:  K75.91
SAR187.49
List Price:  SAR262.50
You save:  SAR75.01
ZK1,304.12
List Price:  ZK1,825.88
You save:  ZK521.75
L231.95
List Price:  L324.76
You save:  L92.80
Kč1,174.43
List Price:  Kč1,644.30
You save:  Kč469.86
Ft18,295.47
List Price:  Ft25,615.12
You save:  Ft7,319.65
SEK kr543.08
List Price:  SEK kr760.35
You save:  SEK kr217.27
ARS$43,653.36
List Price:  ARS$61,118.20
You save:  ARS$17,464.83
Bs344.96
List Price:  Bs482.97
You save:  Bs138.01
COP$194,549.13
List Price:  COP$272,384.35
You save:  COP$77,835.21
₡25,038.42
List Price:  ₡35,055.79
You save:  ₡10,017.37
L1,232.29
List Price:  L1,725.31
You save:  L493.01
₲370,833.91
List Price:  ₲519,197.15
You save:  ₲148,363.23
$U1,917.12
List Price:  $U2,684.12
You save:  $U767
zł201.11
List Price:  zł281.58
You save:  zł80.46
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.