How to Handle BootStrap Login or Popup window in Selenium Webdriver

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey hi everyone this is mukesh for learn - automation comm in this video we'll talk about how to handle bootstrap log in a pop-up window and selenium-webdriver so for many of you you must be new for bootstrap so let me show you what exactly I mean by a bootstrap login or pop-up window and selenium-webdriver so let us talk about high-level agenda first we will talk what is bootstrap modal window or you can say boot a bootstrap model window dialog and how to handle this kind of model windows so [Music] solutions it's very straightforward it's not a separate window alert it means you can directly perform any operation based on a requirement so let me show you how it looks like I have created one example for this so if you are not aware of bootstrap I have already discussed in my previous tutorial what is bootstrap and how it is getting consumed in many of the application so you will find the bootstrap model dialog here in the bootstrap section from the w3 school calm when you click here you will see a separate window is coming right so what exactly means a model plug-in is a dialog box or a pop-up window that is displayed on top of the current page so when I say top of current page it means it's not an alert window it's not a separate window so you can perform any operation directly on it so I just simply copy pasted this code on my blog so if you want to create your own model dialog you will find this code here so I could just copy pasted code on my blog and I just did some modification so if you click here you will see some model dialog will come way it will ask you username password and logging right so now you can see the same scenario has been adopted by many of the application so even if you go any web application nowadays you will find this model window even if you go with make my trip boy booboo Red Bus you will find this kind of pop-up so when you click on signup this pop-up will come so this is called the bootstrap model dialog even if you try with red bus you will find the same in some of the application you will also find the frame scenario so I will show you how you can handle the frames as well so let me show you one by one so I will go to eclipse and I will create a new class and I will say handle model window okay I already written the code for starting the browser and opening the applications I just copy/paste from a previous example and now I will provide my blog URL so it's all it will start Chrome browser it will start my web application and it will set them for sit weight of 30 seconds so now let me click on this so I click on this inspect in fire path you can see a very lengthy XPath is coming which is not reliable so let's write our own XPath you can see one text is coming on top of this button called click here to login so we'll try to search for a button where text equal to this so you can see one matching node so we have written a very good expert so let's go ahead and I will say driver dot finally mean by XPath and simply I will say dot click so when I say dot click it will start with this model window so you can see very then the XPath is coming again so you can write your own XPath as of now for this example I will simply copy paste and I will write my username called mukesh underscore 50 it's very straightforward I am NOT writing any switch operation and if you run this code you will see it will work without any exception so it will start application click click and it will type location driscoll 50 right now if you try to see the same scenario in different web application so let me show you with go I ebook you can try with your application as well so let's say if I want to click on sign up first now you will find one tricky part here so as of now I will take the expert but I have very important trick here to tell you so if I want to write my own expert I can see it's a hyperlink so I will write hyperlink which contains text equal to sign up so you can see even though I have written a very unique expert the two matching nodes are coming here you can see here so one is this and one more so this is not visible and this is visible so what will happen if I try to use this XPath which is matching with two nodes so let us try I will simply clone this handle model window I will copy paste yes so I will go and update the URL because this time we are going to travel Hawaii bow let me just update go I will be calm and implicit will remain same now I want to click on signup link so I will X part which is matching with two nodes now as I told if I click here this will come now if I want to click on this or I want to type something on this I will directly take this XPath and I will say send keys again I will use my username occasion to score 50 so let's run this test okay so now there's a trick and the trick is even though it is was it was matching with two nodes it clicked on the first one so this is the tricky caution you might get in interviews what will happen if one XPath which is matching two nodes and if it perform operation then it will always select the first element and it will perform the operation so in our case it automatically picked the first one and clicked now you can see it's not entering the username and I will tell you why now if you check closely this is coming inside a frame so you can see this authen or key frame right authentication frame is coming so first of all we need to switch to this frame then only we can perform operation so even if you check Redbirds another application you will find same thing but it will come inside a frame so if I want to click on sign up with Google so you can see this is coming inside a frame frame dot model frame so always make sure in my example you will not find any frame because I have not created any frame so you can see it's coming on top window so just make sure if you're doing any operation if it is coming inside frame or not if yes then you have to switch to the frame first then only you can perform any operation if you are new to this frame concept then I have already posted one video on how to handle frames in selenium-webdriver I will provide you the link at the description so you can go and watch that video first so as we can see it's coming inside of frame so first of all I will find that frame so I will go to this HTML tab and I will go to that element now slowly I will scroll up and I just checked you can see the complete HTML is coming inside this frame so we got this ID so before doing any operation I will switch to that frame first so I will say driver dot switch to dot frame and I will provide the frame ID this time it should work because we are trying to switch to the frame first then we are performing a new operation and one more thing until the page is not load fully it will not move to this so some sometimes even this page is loading in the background it will not move to the next statement so once the full page is loaded then only it will move to that line number 24 which is nothing but our username so let's run this job application and you can see the page is loading in the background even though it's not visible although you can see when ad also is coming in the background it might take some time but it will enter email address yes you can see it has entered Mukesh underscore 50 I have given the emphasis of implicit weight of 30 even if you want you can decrease or increase and it's very straightforward you only need to think take care about the frame if it is coming inside the frame then switch to the frame first and then move now then move forward so even if even in Flipkart you will find this so many of the applications now adopting this kind of bootstrap model and dialog window so if you see if I click on login this is coming and if I will if I will see whether it's inside frame or not is in Flipkart it is not inside a frame you can see it shrink top window so in some application frame will be there but not in every application so just go ahead and try all the scenarios okay so we had that now so just try with your application I got this quote from Internet success is achieved by and maintained by those who try and keep trying so keep trying with different application and let me know if you find any doubt thank you so much for watching video you can share with a friend if you find this video useful hit the like button and I will see you in the next video have a nice day bye bye
Info
Channel: Mukesh otwani
Views: 73,448
Rating: undefined out of 5
Keywords: How to Handle BootStrap Login or Popup window in Selenium Webdriver, Handle Login Window, Handle Popup window, Selenium Webdriver, Selenium, Automation, Test Automation, Selenium Webdriver Tutorial
Id: lH-LhPatDfE
Channel Id: undefined
Length: 11min 12sec (672 seconds)
Published: Sat Nov 26 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.