Run Selenium Test on MS Azure Pipeline || Azure Cloud

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this conference will now be recorded hey guys this is navina welcome back to naveen automation labs so guys today i'm going to talk about one very very demanding topic that a lot of people were asking about how will you execute your test cases on as your pipeline and i thought of doing some experiment and then i did one poc and then i i was able to execute selenium test cases very i mean and then uh it's very simple very straightforward guys so just need to know that how to execute that few days back i have already created how to execute your test cases on aws cloud now today we will talk about azure cloud okay so uh what do you have to do first you have to login to azure.microsoft.com so you have to go to this azure.microsoft.com you if you don't have any account please do it and it's pretty simple you can create a free account over here and after that you need to sign in over here so i'm going to directly going to sign in over here and just click on sign in that it will automatically pick your microsoft account you can pick with gmail.com also whatever when you are going to sign up enter your email id and the same email id you have to give it over here i'm going to sign in now so when you sign in it will give you the azure dashboard you can see it over here like that after that what you need to do that you need to go to directly you can you have to go to their devops console over here so you simply write dev.azio.com okay like this you can go to this particular website this particular address you have to enter because you have to go to their azure devops right and then you have to click on start free so when you click on start free then you will be landing on there uh as your console just like we were having aws console right same thing you will be having it over here the moment first thing you have to do that first you to check that okay you are in azure devops what do you just need to do that you need to click on new project so here you have to create a new project see this one project i've already created you need to click on new project let's see and a new project let's see i'm going to give that is uh let's see selenium demo uh description i'm simply writing uh test uh selenium automation on azure something like this you want to create this particular project public or private let's make it public only don't make it private and private means it's uh you know i will available for everyone on internet you simply click on create when you click on create it's saying that okay your project is being created right now so let it create so you will see that okay this is a complete dashboard for that particular project you will be getting it you can see that this is a selenium demo is a project name under this particular account selenium demo overview and this is a summary dashboard is available over here like that what you just need to do that you can see that okay you can add number of widgets over here okay if you really want to do it you can do it later this is your account you can again sign out and you can log in with some different account also if you have it and you can see the summary also and then overview over all the projects overview you can do that and then you can go to their wiki documentation also if you really want to create a wiki documentation you can do that for that particular project create a project wiki if you really want to do that and then you will directly go to pipelines so here we will do a pipeline over here so first everything is related to pipeline over here guys so what you have to do you have to create one as your uh pipeline so we are not going to create a typical ci cd pipeline today we are just going to execute one single pipeline which will execute your test cases directly from your github repository so let's click on create pipeline when you click on create pipeline you will see that okay there are two views one this is a normal view you directly go to the use the classic view okay just click on user classic view editor and uh you simply see that okay hey what is your source if you the sources is already available on your azure repos git in that case let's say you have already having some dot [Music] or hosting your code and everything on your seo that is also good you can integrate with your github also or some other bitbucket cloud or svn if you are using it so we are using github and you can give any github connection name over here so let's see this is i'll simply say that okay naveen uh github okay connection what is the name you want to give you can simply give any name over here and then you click on azure using oauth so we have to okay make the connection with the github so i simply going to enter my username password over here for my github okay because we have to authenticate with the github so i'm going to enter my username over here okay and this is map you have to enter your username password for your github repository and you simply click on this i don't want to save it right now and when you do it you will see that okay yeah it's been connected and the connection has been established now whatever the github repository that you have so let's see i'm going to uh i'm going to go to my github repository i simply go to uh let's see getup.com and in github.com you will see that okay i'm having number of projects over here so you can take different projects like that whatever the project that you want to integrate with as a selenium integration with your pipeline you can do that you can search for the repository over here directly when you click on this see you can see all the repositories listed over here so what i'm that i'm already having one project that i have already created which is a very simple project that i was using for my uh aws execution also so what i have done i have used one application that is called freshworks.com and i'm launching simple my test cases on the basis of chrome and firefox and three test cases i have written first i'm checking that okay logo is there or not logo is displayed then assert true is flagged then i'm checking that okay a title is there or not and then i'm checking it okay all the footer links count is equal to 35 or not simple so these three test cases i'm writing and then finally i'm using driver dot quit over here like that okay and this is at the rate after method i'm using it for every test i want to execute or you can use at the rate after uh you know test also if you really want to use that okay so three test cases i have written like that and uh i'll be executing these three test cases through my uh testing.xml file so the testng.xml file i'm maintaining over here you can see this is my testing.xml and uh i'm using parallel equal to test so i have created two tests over here one is for let's see google chrome and one is for firefox right so i simply say that this is my freshworks chrome test and i'm saying that okay this is my freshworks firefox test so as a parameter i'm passing parameter name equal to browser value equal to firefox valuable to chrome over here and the same test file i have given as a class so you must be knowing about all these tricks so there's no point of covering once again and then i'm using at the red parameter i'm using browser over here and using a string browser over here like that this is the holding parameter which will be picked from this particular parameter and i'm using the same browser over here which is equal to chrome or not and then on the basis of that i'm putting one simple else if condition over here tomorrow if you really want to execute on docker container or selenium grid hub or something like this you can give the ip address of that particular hub url also you can do that that i'm not doing it i'm simply launching driver equal to new chrome driver and something like this right so this is the test code is written and yeah now what i'm gonna do that okay i'm going to uh go to properties i'm going to push this particular code to my repository so let's push this particular code to repository so for that i'm going to create one wrapper over here so let me create one rapport new rapport and my rapper name let's see i'm going to give let's see azir selenium demo this is my repo and description i simple right as your selenium test run public repository click on create repository perfect now i'm going to go to i'm going to push this particular code to my repository because obviously azure will pick the code from repository only not from your eclipse or from your local right guys so i'm going to uh change the directory okay i'm already in this particular directory of our project first quickly let me check the status okay yeah and i'm going to uh first commit this particular code so i'm expecting that okay you guys are already aware about git commands and everything so please check my videos on get repository and everything how to push the code first time please check it it will be very helpful for you and then i'm simply saying that okay uh updated my freshworks code something like this okay i have written perfect and the comment is uh done and then i'm going to simple check the status once again okay but before that we have to get add okay let's commit and then i'm going to push the code so simple get push origin master okay so it's saying that okay let me take some one second okay let me do a hard push that doesn't matter right now okay so you see that okay the push is done and you see that repository is this is my repository and you simply refresh this particular page and you should be able to okay so the code is not there i think what i'm gonna do that let me just do one thing okay let me i think i've already pushed this particular code to some other repository you have to change this particular url so sorry about that because i was already working on this there is already repository is available and the url is already available so let me just change this from here sorry about that so exact url that you have to add it okay now this is my new repository name let me just save it okay now i'll do one thing let me make the connection with this okay now let me uh check the status okay nothing to commit let me comment let me push the code now okay now it is pushing so ultimate target is you have to push the code guys so sorry about that that confusion that the code is already because repository is already available there is a separate repository is already available i have created one more repository so that's why i have to update the new repository url with my existing a local repository now you can see the code is available over here okay two minutes ago the exact code is available over here like that same thing guys what i have done that in my form.xml file also because we are going to execute through the maven command from the azure make sure that in your pom.xml file in your surefire plugin okay you go to your shortfire plugin make sure that uh your testing.xml file path is available over here because maven will execute pom.xml file.xml file will check where where is your surefire plugin and then it will pick your testng.xml and from testing or xml it will pick your test cases and the parameter from here okay so this is a first part is done now you go back to your azure pipeline and then you search for your repository over here so you simply go there and whatever their uh repository name so this is the repository name as your demo so i'll just copy this and you simply paste it over here you should be okay let's do one thing let's refresh this particular page once again we just created one repository so let me go to github and let's search that particular yeah now you can see that azure selenium demo that we recently pushed the code to this particular repository and you simple select from which branch you want to do that from the master branch and then you simply click on continue and here what you have to do that you have to select maven so click on maven because our project is maven based if you have net or asp.net okay or python then you have to use the respective language but we are using maven over here click on apply now here you will see that okay this is the some information that okay yeah selenium demo maven ci or something that okay it's written as your pipeline on which platform you want to run on which operating system let's say i'm going to run my test cases on mac machine or ubuntu is for linux and then windows and then windows 2019. so let's see i'll be using mac machine and what where is your power xml file so my pond.xml file is available in my root project so this will be like this you click on this maven point symbol and here you will see some more information you can change the path over here if you really want to do that let it be like this maven powered xml file you can change the display name also that's okay and uh what do you simply do that okay what is your main goal so may one goal is let's say i'm going to use clean install maven clean install no need to write mbn you simple right clean install over here now one thing is that guys that uh this does not support any test ng um you know any test ng report any test indeed test results by default it will take j unit and i haven't seen any option for test ng so but in test ng also when you execute it test ng will internally generate junit report also you must be knowing that okay on top of a testing g i mean on top of j unit test ng libraries are available and then when you execute your testing g test cases after the execution it will generate your testing g dot xml as well as i mean your the result will be generated from the test ngo example it will generate index.html and all those files and internally it will generate some junit xmls also so we will give this particular path from the june.xml so make sure that okay you're giving this part surefire report and test hyphen star.xml it means whatever the file is available with test hyphen.xml starting with this take that particular file and generate as a report and then you right now we don't have any code coverage if you have any code coverage you can write copper or jaco code they support these two things perfect and after that what do you just need to do you just need to click on save and save and queue queue means run or you can simply save it you simply let's you save it and if you really want to put a comment over here simple write a comment otherwise you simply save it over here when you save it you go to pipelines once again and you see that okay one pipeline got created selenium demo maven ci now you just need to what you need to do you click on run pipeline when you click on run pipeline it's saying that okay hey on which agent you want to run so i want to take let's see on this particular mac machine 10.14 run you can enable system diagnostics also some logs will be generated for system point of view and you simply click on run when you click on run you will see that okay will create one agent job you can see that build got triggered just now from the master branch from this particular repository and you simple you can see the changes also what kind of changes that you have done okay you can simply see the changes over here that okay updated my freshworks code whatever the code commit a reason that we have given the same code commit reason will be displayed over here you go back and click on agent job one when you click on it you can see that it will create some some sub jobs over here some uh task over here for the respective job and you can see that okay my maven clean install is happening over here like i hope you can see so see uh first it will download all the artifacts whatever the format xml file dependency that i have added all uh you know web driver manager or selenium or if you have any apache poi api or sng.jar file or whatever first it will going to download all those artifacts those resources and then you can see that okay it's executing my test cases can you see that all the footer links are getting displayed over here right you can see my reaching at the test level and you can see that okay chrome driver started successfully and see all my test cases are absolutely working fine and my test cases complete maven xml file is perfectly fine and then artifact is published and then finalizer top is also done it means finishing the job what you just need to do you go back and here it will generate one test tab over here you simply click on test tab and you will see that okay the result over here my hundred percent test cases got passed you can see it's a simple click on it and you can see that filter it out.okay include pass pass on rerun not impacted or others and you will see that okay get footer link text get rid of link text fresh work logo test because we are using two browsers right one is for chrome and one is for firefox so in that case what will happen uh three test cases i have written over here and two tests i have created i mean one is for chrome and one is for firefox so three plus three multiplied by two means six test cases should be executed you can see three address test annotations i have one two and three and footer links get footer links get fresh works title test and freshworks logo test that i have written and you can see the same thing over here okay so later on you can rename the brow uh rename while reporting that is a different task that we can do it later that like get footer link test for firefox and chrome and all those things that is a different thing that we can you can do it later but you can see success cases got absolutely working fine now what i'm going to do that now i'm going to make some failure so uh let's see deliberately i'll make this is the css director i'm using it deliberately i'm writing one one one all right so i'm making this particular test as failure now so how to do that now i have to execute once again right so what i'm going to do that i have to trigger i mean i have to push the code once again because the code i have updated in my local and i have to update my code i have to push my code to my git repository as well so let's do a one more commit get first of all let's do an ad over here let me write it and push the code okay so code has been pushed now you can check you refresh this particular rapper and you can see 13 seconds ago updated my freshworks code you go to this pipeline once again go to this pipeline and we have to click on this and you can run this pipeline once again so to run it again on which machine on mac machine from the master branch and click on enable system diagnostics click on and you can see that uh let's see the changes you can see the changes is again updated my freshworks code whatever the code that okay the commit reason that we have given go back click on agent drop one and you can see that okay my job got started once again so first it will initialize the job and uh check out the repository from okay from that particular branch from the master branch and then maven bomb.xml file means again download the artifact and everything and prepare your test cases execute your test cases so again you can see that okay again it's going to download my test cases so let's wait for few seconds and this time my one test case should be filled that logo test should be filled okay so let's wait for few seconds so it's pretty fast and uh later on you can try on windows machine also or on mac machine also or linux machine also so now you can see can you see that my test case are running fine see these are the footers are getting printed whatever the code that you have written for the footer see same footers you get the footer list and printed using the for each lambda function or you can use a for loop also and for every link i'm printing the text over here that's why you can see for every link the test footer link is getting printed over here right and if you really want to see the raw logs also you can see that you simply click on this you can see the complete locks over here like that or if you really want to see it over here you can check it over here as well now you can see that okay one test got uh failed why because obviously that uh my one test gate got failed so you can see out of five one got failed right then which one got failed we can see that logo test you can see see the logo test got failed i hope you can see over here you can see the logo test right and unable to locate this particular one one one freshworks that we have already changed the logo cs selector we have already changed now i'm going to go back and uh click on the test now this time you will see that okay yeah two test cases got failed why because one for chrome and one for firefox you can see these two test cases got failed and whatever the failure reasons you can see that complete stack trace you will be getting it and yeah unable to locate this particular element complete stack trace also you are getting it any history or any kind of a log attachment also you can see it over here like that complete history you can see that okay earlier it was working fine but now it got filled you can check the graphs and everything you can check it over here like that and complete history you can check like that if you really want to raise a ticket or bug if you really want to do that if you really want to associate any bug you can do that create a bug directly from here okay see the bug will be created in your team foundation server i think okay that you can simply save and close and then you can simply do that okay let me just uh save it okay so bug will be created the bug number will be created like that and code coverage right now we are not using it this is the summary you can get it once again you simply go back to agent drop one simply go back go to test once again and you can see if you really want to see all the past results you can simply select the past one also you can see footer link and title test got passed but logo test for firefox and chrome both are not working because css selector could not be passed over there so this is a success rate you can simply see you go back to pipelines and then you can simply see that okay yeah this is the pipeline that we have created and two times we executed so this is the build number you can see that 725.1 725.2 one got pass second got okay failed like that okay so likewise you can simply see that okay this is the current status of the master branch earlier it was absolutely working fine and now the second one is not working fine because of some failure so it will you can keep monitoring like this also you can see the trend okay that 2.5 to that last last run got failed right guys so this is pretty awesome and you can configure some uh graph analytics also that you can do it later you can see the few report and pass rate and test pass rate if you really want to see that you can simply see that so i haven't explored this yeah so you just store it okay uh what else other than that uh what do you do that let's see i'll go to this particular thing and then you click on edit once again edit your pipeline once again so when you edit it what you do is you simply go to trigger right and you can simple i wanted okay the moment i check in my code automatically my pipeline should be triggered right it should be no manual intervention automatically it should be triggered so simple click on enable continuous integration and you can simply take from this particular master branch and uh yeah and then you click on pull request validation also like someone is raising the pull request automatically it should be triggered from that particular branch so that also you can do that so it means whenever there is a pull request from the master branch you can do that and uh what else we have yeah so let it be like this and if you really want to schedule a job like let's see every saturday or every sunday or every night or monday to friday every day seven o'clock i want to execute you can simply do that you can simply select the respective time over here let's see every every day eight o'clock nightly build i want to do that or twelve o'clock nightly build i want to do that that also you can simply do this okay so whenever there is a check-in is happening in your repository automatically it will be triggered and you can schedule it also directly from here so let's see this is the container integration for enable in this particular branch batch changes while a build is in progress let it be like this also and this also let's see i have selected now uh let's see simple save this particular pipeline let's try i'm going to push pull push the code once again and let's see it's getting triggered from here or not so let's see so what i'm going to do i'll simply make some changes over here that okay i just simply write that system dot out repentance running title test something like this so this is a change that i have done clear the console and i'm going to add first of all this particular code get commit minus m updated title test and get push origin master so yeah i'm pushing the code to the repository and let's go to your pipeline come over here and let's see it is getting triggered or not you can see yes build number three getting triggered can you see that from the master branch we have one title test which is you can come over here it just triggered just now there are two changes you can see it over here that updated title test okay whatever it's showing the same thing and you can see that uh go to agent job1 and your test cases are getting triggered right guys so this is uh pretty awesome okay so this is pretty awesome you can see that uh again my maven xml file is uh getting executed you can rename although that's not an issue and it's going to download the artifacts once again and uh perfectly fine so let's let it run and let's see the report is getting generated or not so again it's picking the test cases over here you can see that all my firefox and chrome and everything is running you cannot see the browser guys it's running on the cloud it's running on the mac machine somewhere on the cloud on azure cloud on microsoft cloud that you cannot see it but you can see the console logs it means my test case are absolutely working fine you can see the okay the footer links are coming and whatever that you are printing see can you see the running title test this is the system dot auto pin telling that we have written see i'll show you once again what are the system dot out print talent that we have written see um you see over here running title test can you see that the same thing we have written over here in my code running title test right so exact same thing it means my test keys are absolutely working fine and you go back click on test once again again two failures are there because we haven't fixed those problems now what i'm going to do let me uh remove this guy now i'm using the correct css selector over here now i'm going to push the code once again so let us get add and this time i'm writing let's see updated or fixed logo test and get push origin master okay so it's done go to pipeline it show trigger build number four in few seconds see build number four is there perfect and you can logo this is what we have done you click on it go to agent job1 and once again you will see now this time we should able to see all the all the test cases should be absolutely working fine so let's see so this is pretty fast this is pretty cool very easy to execute guys i hope uh you got the idea what it is okay whatever we are doing and one thing also you can do it actually what you can do is um you guys can experiment this thing um [Music] let's see um this is your uh let's see this is your eclipse right and you're pushing the code to the git repository this is my git and this is my local code and this is a pipeline that you have created where in azure so let's see this is as your pipeline and you have picked the code over here like that and you're running your test cases on this particular machine what you can do is that you can create one aws instance uh where your grid setup is available over here through the docker containers that also you can do that and your grid is running on aws let's see like this and you trigger your test cases on aws but the execution is happening the browser is running on aws but the actual execution is getting triggered from azure so that also you can do that some people they do that they maintain their infrastructure for server and everything on on the aws machine and their pipeline and the ldr so this is your uh what cicd pipeline you can do it over here on azure this is your pipeline part right pipeline pl and the execution your infrastructure is set up over here on aws so that also configuration you can do it now you can see that okay all my test cases are absolutely working fine right guys so let me uh erase this drawing and yeah so simple go to pipelines you come over here for build number four all my test cases are absolutely working fine now you can see include pass also all test cases got fixed now you can see you can see the history and now history is perfectly fine okay so likewise guys please do that do some experiments over here it's pretty simple you can do that later on what you can do that okay you can create one release pipeline also you simply go to release you can create a new release pipeline also there is a new concept okay i mean you can do a complete ci cd pipeline you can create a pipeline over here like that let's see you go to simple empty job you create that and uh what you do you have to add one artifact over here from the selenium demo let's see that you have created and then you can add this simple artifact that you can do it okay so let's see i'm taking this that part i'll tell you uh later okay so uh whatever let's see the latest version i'm going to take it and you simple add it multiple jobs so you can add the jobs like this see multiple pipeline likewise you can create that let's see one empty job that i have created so likewise you can create number of jobs over here see one more job got created like that okay like this stage number four got created whatever you let you want to deploy something else that also you can do that okay so empty job you can click on apply and okay let's see you have saved this like this if you really want to delete you simply delete this confirm delete also because so this is a typical cicd pipeline that you can do that otherwise you can simply click on this and you need to click on task and here you can add number of tasks over here so what kind of tasks that you want to add so let's use simple click on plus and let's say i want to add what i want to add a maven task from here so you can select maven from here see there are so many tasks are available see if you really want to trigger one jenkins job also from here that also you can do that you can trigger one maven job you can do that click on add go to this particular maven configuration and everything the same configuration you can do it from here like that also you can do that simple save it and when you pipeline cicd pipeline likewise you can simply do that like this so you can create a template of the pipeline you can schedule your pipeline triggers and everything like this the same way that i have told you pull request deployment also you can do that okay if you really want to execute manually also that also you can do that and simply save it over here like that right and when you uh run it you simply go to pipeline once this is done you go to release and simple click on create release and then if you really want to whatever the pipeline that you have created and you simply click on create so your jenkins pipeline release will be created from here it will be triggered from here you come over here and you will see that my jenkins job is complete cicd python is running from here so that part maybe i can show you later how will you trigger your selenium test cases from the release pipeline so there are two things guys one is the pipelines one is the release pipeline so release pipeline maybe i can tell you later not now otherwise the video will be too much so one more video i can maybe so okay like that yeah so that thing i'll just okay tell you i just giving you a simple basic stuff that what exactly i'm doing it over here now some limitations are there that you cannot integrate like exchange report or ldr report like that i'm still experimenting it's very i mean there is no documentation available like that most documentation for azure you will be finding for dotnet projects but it's very very rare things are available for test ng and uh you know test ng with extend report or ldr report with azure so i think on youtube also this is the first video you can see that we are executing selenium java maven testing test cases on azure pipeline otherwise i haven't seen that i did couple of research from my side i haven't seen that so please do that it's pretty simple try to run it create your account over here and let me know if you have any issues i'm pretty much sure you guys can do it very simple very easily okay but please this code you can take it but i prefer that okay you write your own code and push the code and then use the same code repository in your azure pipeline configuration perfect i hope you like this particular video if you like it please subscribe like comment over there click on bell icon so that for the next video you will be getting the notification thank you so much thanks for watching this particular video you
Info
Channel: Naveen AutomationLabs
Views: 29,857
Rating: 4.9539347 out of 5
Keywords: MS Azure, Azure pipeline, selenium on Azure, Run Selenium Test on MS Azure Pipeline, Azure Cloud, naveen automationlabs
Id: 5S7ev-GMyOM
Channel Id: undefined
Length: 37min 23sec (2243 seconds)
Published: Sat Jul 25 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.