Selenium Integration with BrowserStack || Run Selenium Test on BrowserStack Cloud

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys this is navini welcome back to naveen automation labs so guys in the previous video i have already told you that how to execute your test cases on source labs and today i'm going to talk about browser stack so browser stack is another cloud vendor company which will give you number of vms to execute your test cases on their cloud and you have to pay for it but there is a free account also there is a free version also you can use it with the limited features and limited number of uh execution time and limited number of test cases so browser stack is also a very good competitive uh company with respect to uh us with respect to cloud testing and they will give you multiple devices on their cloud multiple browsers multiple operating systems and everything so what i have done i'm going to do that first thing i'm going to create the account over here in front of you guys so let's see just go to their signup page browserstack.com user sign up sign up with google so let's see i'm going to use some um this particular email id i'm not going to use my so i've created one you know dummy email id and there i'm giving some name over here let's see this is my naveen youtube and this is my account name or something like this that i have created i agree the license agreement and click on continue when you do a sign up and what you're looking to test i'm looking for website and then what kind of testing you are looking for you are not looking for i mean you're looking for manual testing automation testing or the visual testing so we're looking for automation testing just click on automation testing and we are setting up your automation dashboard and uh they will give you selenium grid which is running on their cloud and yeah so this is your uh username or something like this that got created now and it's saying that uh you know let's get started so when you let's get started they will give you as i told you number of keys over here the first key is this is your username and this is your automation key that you have to use that and these are the desired capabilities that you have to add if you're using some other language let's say you're using python so this is a python capability that you have to use and if you're using c sharp or php perl ruby everything the username and your automate key will remain same same thing for javascript also for node page application you can use that we are using java in this case so we will be using these in important information and then we are going to set some desired capabilities and then we are going to execute the test cases so you can get your automation key and everything you can go to your profile and you can go to settings and there also you can get it you can just simply go to settings and this is your automation key for local testing for automation testing this is your access key that you can use that right so let's do one thing that i'll go back and click on let's get started once again and with respect to their java documentation and their documentation is really really great and we can use this and let's see how can we write the code so application wise point of view as i already told you that we have written in the previous uh previous session while doing this source labs we were using this particular application you can use any application you can launch any application url and this is the url that we are going to use and we are going to enter the username password we are going to login to this particular site with this username password and we are checking that okay total number of inventory items as well as add to cart so very simple test case that i have written only two test cases that i have written over here you can check that this is the standard user and the password is secret sauce so this is application that i'm going to use you can pick any application total number of items are say and total number of add to cart buttons also six so that is what i'm checking over here perfect and in the previous example what exactly i've done i have created my base test where in this particular base test i was defining all the browser capabilities design capabilities with respect to source labs now today we have to use with respect to browser stack so i don't want to disturb this particular base test code i'll see i'll do one thing let me create another base test with okay for the browser stack so i'll do one thing that i would write a name something like this browser stack base test okay and click on finish in this particular browser stack base test exactly same thing i'm just going to copy paste let's see from here and then we will modify this particular class accordingly because we need before method and after method over here so let's take this and what are the different things we need so first of all that uh we will do one thing we will come over here in the documentation and we will take couple of things from here so i'll maintain these three uh static final variables so just copy and at the class label i'm going to paste over here okay so this is your username this is your automation key that you can get it from your properties file also later on and this is your hub url last time we were using sourcelabs.com now we are using on browser stack cloud wd hub it means they are giving you the selenium grid hub on their vm and we are going to use that so this is the remote driver url that we have to pass so this will be a username and this is your automation key this is the exact same thing we have done earlier that this is the on-demand user source labs 443wd hub and that was my username and that was my key for source labs here exactly same thing username automation key that we have to pass it like that now in this particular case we don't need any uh mutable capability so you just remove all these guys and let's copy this we need to create the object of this and use all these desired capabilities so let me just copy paste so we need to create the object of desired capabilities os windows os version 10 let's see browser chrome browser version 80 name is equal to something like this you can do that and we will parameterize it after that uh let's see browser is chrome so we have to pass at the key as browser for chrome browser for firefox but remember one thing when we pass the chrome name we have to pass capital chrome and same thing for firefox capital f and we don't need this because these are the common properties that really want to use okay for chrome and firefox and we are going to use caps over here so let's use caps hair caps perfect and what is the on demand this is the url of the cloud and then we are going to replace this particular url from here so i'll be using this and using caps right now if you remember that last time i uh created one testng.xml file same thing we are going to create one more desng.xml file where we are going to pass all these all these parameters browser name browser version operating system operating version name operating system version name we are going to pass it from here only so let's see we are going to create one xml separately for browser start let's create a file i don't want to modify the same uh regression file so i simply say that okay this is my sng underscore browser start okay browse the start dot xml so now this is done i'll do one thing i'll go to my regulation.xml that i have created copy this and paste it over here entirely and then we will modify accordingly so this is instead of sourcelabs i will say browser stack okay browser stack test automation regression suite i want to run it in parallel mode let's see this is browser stack on firefox browser stack on google group now remember one thing that here you have to pass operating system and operating system version separately okay because earlier in source labs windows 10 we are passing together but here you have to pass windows and 10 separately so how to do that so first of all i need os os version so i'll be maintaining a couple of things first of all i need os i need os underscore let's see version and what else you need you need browser and browser version so i'll be using browser and i'll be maintaining one more parameter browser version okay let's see browser underscore version something like this so which operating system so operating system i'm going to use windows so here we have to use windows for capital w okay sorry i'll be using windows over here and uh os version that you want to use windows 10 so we have to use n over here which browser you want to use i'm going to use capital c chrome okay no sorry this is for firefox i'm going to use firefox on windows machine and what is the browser version that you want to use so let's see for firefox um okay so what you can do is that you can uh go to fletc for firefox i want firefox 80.0 okay so there is a configurator is also available we can create our own desired capability configurator that i'll show you in some time okay so yeah okay other than that uh soft lab source test is the class name that is fine now i'm going to use all these four parameters for chrome as well so let me just copy paste over here and now this time i want a mac machine so a mac let's see they just click on this here you can select your mac let's see os catalina and i want that for chrome i want chrome chrome e okay so 85 do we have okay it's not giving you the 85 but uh what i can do is uh let's see chrome 81 can we take it and here you have to use operating system os x now so accordingly on the basis of these drop downs the values will be changed over here so the os value is for mac machine you have to use os x this is for mac os version is catalina is the version name and the sorry i'm changing over here sorry i have to change it over here this again i'll be writing os x it's pretty simple guys that and then i'll be using chrome so i'll be using capital chrome over here and the browser version instead of ad1 let's see i'll be using 85.0 okay so let's see 85.00 so browser version and the class name will remain same so how many test blocks we have these two test blocks one and one is for chrome one is for firefox and i want to execute in the parallel mode perfect then i'll go to my uh source test.java instead of base test extending i'll be using browser stack based test right and the application will remain same your test will remain same i'm just changing the browser's tag based list so i have created a separate base test class so that i don't want to mix over here and i'll be pushing the same code to the same repository so that you will understand okay this base test is for for source labs and this is for browser stack okay so then what we have to do we will go to our browser stack and here we have to take the parameters so what kind of parameters you need first of all that you need browser you need browser version so let's see this is the version and you need operating system os and you need one more that is called os underscore version parameter okay which is we are taking it from there from your test ng.xml that you have already created os os version browser browser version that you have to take it so okay so okay sequence doesn't matter so browser will be given to browser name version will be given to let's see i'm giving to the browser underscore conversion this os will be given to string os then i'll be creating one more string over here that is the os version so is underscore version comma method okay to pass the method so method name i'll be getting it same way over here and instead of this particular method name this hard coded value i'll just remove it i'll remove okay using this guy what is the os world os you are using the same os i'll be using it over here so remove this hard coded value what is the os version so os underscore version that we are going to use it what is the browser version browser version is this that we are taking it from xml file and uh that's it right same thing for firefox we don't need this let me remove that so let's see it is working or not okay so i think it's almost ready and we just need to execute the xml file now run as testing g and let's see [Music] okay let me see the result over here it's still missing it's saying that version is required okay so we are missing one version over here let me just terminate this so let me check once again that uh os os version browser browser version so i'll be taking browser browser version okay we have to pass exactly same thing browser underscore version we have to pass right and the browser parameter is browser browser version os os underscore version perfect okay great now let's run it again so whatever the parameter you are passing from the xml same parameter you have to pass it over here so let's run it and let's see yeah this time it's picking and we have to come over here and we have to go to the live dashboard so go to your dashboard over here so that you can check your test cases are running or not okay it's saying that's clicking on again so you can see that okay one session got created somewhere over here and you can see that session name is check inventory item test completed on see these are my test cases are absolutely working fine how many test cases four test cases two on chrome to one firefox you can see that uh all absolutely working fine four test cases got passed over here right you can see and you can see that i'll show you just go back to the dashboard and these are the four test cases out there right guys so what do you think is still one is yeah almost done and check add to cart button on mac os with chrome 85 it took around 12 seconds so entire list is available over here you can check it so let's see what happened to this guy and you can see the live preview the recording also you can see it over here the artsy it's launching and entering the url in some time username password clicking on login button and done super fast and you can see all your logs over here you can expand all the logs you can see that first we enter this particular url then we have entered id equal to username this then we have used this password then we have entered the password then we have clicked on login button then we are checking that the value and then finally driver.quit to stop the session and these are the capabilities that you can see over here along with the method name so this is like pretty good as uh like both are exactly same i didn't find a big difference between source labs and browser stack but personally i would advise you to use browser stack once uh their speed is slightly good as compared to source laps but the only thing is they have very limitation and with respect to execution everything you have to pay for it but anyways so it's saying that okay free plan has 100 minutes remaining so you can use this free ban only for 100 minutes okay but you can see that if you go back let's check it on windows also once again on windows 10 uh this was a test and see on windows 10 see it's running you can see the video once again and it's running on google chrome windows with chrome you can see over here and it will enter the username password let's let it launch yeah entering the username password checking add to cart and everything perfect and you can expand all the logs over here and if you really want to see the raw logs you can see the locks the complete locks that you get in selenium also exactly which api they got call and everything you are getting it over here so this is pretty really good feature and uh the ui also pretty user friendly you can see that go back and then you can see see this name is coming because of this particular capability that we have passed right case name is the key and method name that you have to pass over here so likewise they have multiple capabilities you can check in their documentation so let me just okay let's see you want to go for documentation for java so the documentation is really good they will give you each and everything step by step over here and if you really want to debug if you really want to debug you have to pass this particular capability if you wanted okay no i don't want to take any video so by default it is true you can make it false if you don't want to take any videos over there so likewise also you can do that and run test in parallel that i've already shown you so likewise there are multiple settings over here guys that you can use it see this is i'm talking about capabilities builder you can create your own capability and automatically you just copy paste and you can select your language over here so let's see if selecting java i wanted okay on my operating system is let's see on windows 10 i want to execute on google chrome somewhere on 85 and the resolution also you can select which selenium version that you want to use chrome driver version what is the project name what is the build number you want to use and what is the name of the test run that you want to use that you can simply do that and uh perfect and uh enable browser stack local true debug if you really want to do that if you really want to check the console and everything so on the basis of that let's see record is true selenium logs is equal to true so they will give you all these desired capabilities you just select it and then run it so let's see my build number is 1.1 something like this so automatically this desired capability will be created for you if you're uh let's see this is my login test so one method will be login test capability that you have to pass right but we don't want to use this particular hard coded value so this is just for creating the desired capabilities you can see it over here you can use your and you can parameterize remove the hard coded values and pass everything from your xml file or properties file or whatever you want to use that that is up to you right so this is about the browser stack guys i hope uh there is no big difference if you know soft labs the exactly same thing the concept will remain same with the browser's stack as well it's just a matter of their cloud dot com name will be changed with uh grid and for source labs will be changed you will be having your own username automation key for browsers tech separately okay so i'll do one thing i'll just push this particular code to my repository so uh let me do it right away so that you will get this entire code to the repository as well so let me just quickly check the status yeah so again add this let me check the status once again get i'm going to commit minus m added base test for browser stack configuration okay and then get push origin master now the repository is available perfect so this is the repository url and i'll share this repository url in the description of the video also if you really want to use that you can see that so here you will see that that's the name source labs i'll change this name later on but here it's having both the okay both the configuration base test with source labs and this is where the browser stack you can take this particular code and practice accordingly okay guys so thank you so much thanks for watching this particular video guys please subscribe to the channel and press the bell icon and if you uh really liking these kind of videos please subscribe and share this particular video with others thank you so much guys
Info
Channel: Naveen AutomationLabs
Views: 23,810
Rating: undefined out of 5
Keywords: selenium, Selenium Integration with BrowserStack, browserstack, Run Selenium Test on BrowserStack Cloud, selenium with browserstack, saucelabs vs browserstack
Id: do_nCul11LU
Channel Id: undefined
Length: 22min 21sec (1341 seconds)
Published: Sun Sep 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.