Full transcript of “Playwright Interview Question & Answers - Part 1 (Latest - Most Asked) By SLT Learning”. Click a timestamp to open the video at that moment. Need another video? Use the YouTube transcript generator.
0:02 Hey guys, welcome to SLT learning and this is Ankit Praapati and today we going to start with the list of interview questions for playright automation. So this will help for the fresher as well or the person who has the experience in play writer as well. they will come to know about the key common questions that going to be asked in most of the MNC companies and they I have like sorted out around the most asked interview questions and I'm going to make the series at least of 100 questions related with the playright with the different level of experience and different level of the interview uh techniques that you can crack. So let's start with the uh with the first 10 questions that we're going to take in this particular video. And if you want to schedule your mock interview with our
0:49 expert, okay, then you can call us call the call on the given number or you can also send the email for the detail with your resumeum and the time slot that you prefer for your mock interview. So we will arrange the expert that going to take your mock interview and that will help you to gain the confidence when you face the interview or o or the video call or the face toface interview. Okay. So let's jump to the first part of the playright interview questions and let's see what we going to cover today. So these are the uh list of questions uh we going to cover in the first part. Okay. So the first thing is that what is playright? Why playright is important and why people started using the playright like we already have selenium and all those things but why people jump
1:34 to the playright side how to install playright and how to install the different browser in playright. So these are the common questions they're going to ask you. If you're a fresher, they're going to ask you the basic questions like that way as well. They wants to know if you have really work on playright or not. How to run the test in a different way in a playright. Then how to generate the different reports. What is await and sync in playrite syntax? What is playright fixures? Then what is difference between npm and npx? This is not related with playright but I have kept in this uh part one. Why? Because few of the questions we need to cover like they going to ask related with the node and so because of that like I have included that questions that I have seen
2:20 in one of my panel interview. They have asked this question to the candidate. Then benefit of cross browser testing. Okay, this is again not related with playright core. This is applicable to the automation side as well. So we will see what best answer you can give on this particular questions. Then how to perform the cross browser testing in fluoride and how to execute the local how to execute the your script in the local browser. So these are the 10 questions that we going to cover today and I will show you each and every syntax as well. And if you want these presentations you can just ping your uh email address in the comment box and request for it. I will convert it to the PDF and I will give it to you for your learning purpose. Okay. So let's go next and see what is playright and why
3:06 playright is people have started using it. Okay. So first of all let me tell you the playright is the open-source automation framework which is developed by Microsoft. Okay. And playright is useful for end to end testing in the modern web application where we have the ReactJS and AngularJS and all those things. So those kind of the application we can do the end to end testing like the automation testing using the playrite. Okay. It allow you to write a test case that simulate the real user experience and real user interaction across the different browser at the same times. And that is the one key things that people started using the playright. Playright support multiple languages, multiple browsers and that is the one things that playright is like now nowadays is very use very adopted uh
3:54 automation tools in different uh projects I will just says. So the key things you can answer like that way the key things the the the highlights in a blue you can also speak like that way if you do not want to go in detail you can just says playright help for the cross browser support right playright support cross browser testing then it supports uh support cross uh platform testing then auto waiting this is one of the crucial I will just say is the benchmark for playright it it allow you to automatically wait for certain event to be happen with the element where in selenium we have To wait, we need to implement implicit weight, explicit weight, fluent weight and like pace synchronization mechanism. But in playright, you no need to worry about those kind of events. It will be automatically handled by the autoate in
4:40 a playright. Okay. Then playright support the powerful selector like it supports CSS XPath then text selector then rolebase selector. I will just say that is the one unique things you will see if you're automation engineer you must be aware about CSS and the expert. But in a playright you will see the role based selector that questions that I have covered in one of the videos. So I will I will talk about in much detail how the get by role uh locator work in playright. Okay. Then it has built-in test runner. So playright will help you do the parallel executions retry on failure test cases taking a screenshot and the videos of the executions. Then you can generate the HTML report. You can also integrate with the lure report
5:26 those kind of stuffs you can do with the playright. And the one of the key things like as a automation tool right it has the code gen tool which help you to record your test execution right and based on the recording you can easily generate the automation script and for that you need to simply run a command npx playright code gen and the your application URL and it will automatically start like if you know the selenium IDE right where we go and record and record the things and we export the script. Similar way this code gen tool will work in for the playright where you can record your web interaction steps manually and it will generate the script for you automatically then playright support API
6:14 and mobile application testing as well and that's why it is also more adapted it's getting more adapted with the different projects it's it's fast and reliable like when we talk about the advantage then few of the keywords we need to use and that is good to be answer in interview as well. Fast and reliable. The playright automation is very fast. It's easy to use. It is easy to adopt to do the certain things and that's why people choose the playright. Okay. So the points that I have marked in the dark blue you can speak about those point as well as initial they will understand your answer will be on the 9 or 10 out of 10. Okay. So let's go to the next question. how to install playrite and how to install the supporting browsers for the playright.
7:01 So sometimes they will ask you the command. They will if they are in a video interview they will ask to share your screen or they will ask you to okay put the command on the chat. Okay. So you should know the basic command. I will not just says you should know everything the coding part or or the advanced command but yeah installation you should know npm install hyphen d and at the rate playright/ test. Why hyphen d? that is the flag which help with the node to download the development related dependency and that's why we use hyphen d. Okay. So this is how you can also explain npm is the node package manager and it will help to install the playroid test. Then how you can install the supporting browsers for the playright
7:47 right? Then another command will be npx playright install little bit different but this second command the node package executor will install the actual browsers related dependency to work with the automation. Okay. So these two command you should always remember. Let's jump to the third questions. How to run a test in a different way. Okay. So if you if you have really work on playright or if you are learning the playright you must be know right there are a different way where we can execute the playright uh automation script. Okay you can go with the tags you can go with the parallel mode you can go with the headed or headless mode there are different ways. So how you can run those things okay so the first things I have
8:34 mentioned over here the basic test. Okay. So how you can run the basic test the npn playright test that means it will execute all your test cases which is under the test directory okay let's suppose if you have three to four test cases it will execute all of the test cases which is under the uh test directory okay only simp by giving this this command this will execute all so suppose if they will ask you the question in that way how you can execute all the test cases at one go okay then you and say this command npx playright test. Okay. Now suppose you want to run a specific file. Okay. You want to run a specific file. What you can do? Then same command npx playright test. Then folder name and give a name of the
9:21 specific file. This will help you to run the specific a test case. Okay. In a playright. Then again suppose you want to run a test case by the test name. What you can do? You can do the same thing npx playright test - g for the grouping and grabbing the test case name and then provide the test case name over here like homepage has title. This is the test I want to execute. So what we will do the playright will go to the test file and identify which test case has this title and it going to execute that particular test case for you. Okay then run in headed mode. What is headed mode? Headed mode in simple terms it will show
10:06 you the actual browser execution. Okay. And headless means it will not show you the actual browser uh uh I would just say actual browser. So how you can run in a headed mode npx playrite test if you want to give a specific test file name then include this one and then double- headed. This will help you to run your test case in a headed mode. Okay. Now suppose most of the times when you want to debug okay some error or failure right what you can do you need to like in in Eclipse or somewhere we normally put the debug point and we execute our script but what you can do the same thing using the command line right you can run in a debug mode with the inspector so what you can do just put this particular uh command in your
10:54 executions npx playright test then hyphen debug and this will help you to execute your test case in a debug mode where you can see the inspector, you can see each and every locators of your steps and all those information. Okay. Then the next things will be the run in a parallel or serial mode. Suppose you want to run in a parallel mode then I will just says in playright the run in a parallel mode will be default. But suppose you want to uh do it by the serial like one by one or sequential way then you need to describe that particular uh this particular flag this particular mode serial mode into the uh playright doconfig file. Okay. So once you configure that particular things
11:40 this will uh this will execute in a serial mode and by default it will be available in parallel mode. Okay. So now you know how what are the different way you can execute the test case or you can run the test case in a playrite. Okay guys let's go to the next question. How to generate the different reports in playrite. Okay so when you execute your test right and you want to generate the different reports what you can do. Okay so first things you need to configure your uh this is the command you can use but you need to configure playright.config.ts DS using this particular configuration. So you see the reporters right these are the the reporters means different different kind of reports available in playrite. So when I just says reporter
12:26 HTML that means I am asking playright to generate default HTML report of my all the test cases and do I need to open it? Never. I do not want to open it automatically. I will open it manually when it required. But suppose you want to give it the different function. Okay. on failure I want to report I want to open that report automatically or always open the report automatically or never so these are the three parameters you can pass it over here in your reporters and these are the different reporters available in the playright built-in reporter so let's suppose I want to execute the and generate the HTML report what I can do npx playright test - reporter is equal to HTML this is the manual this is you can execute when you
13:12 have not configure this part. If you once configure this reporter in your config file, then you don't need to give it like this way. It will automatically generate the HTML report by default. Okay. And how we can view the report. So simple npx playright show report and this will open the report that has been generated by your execution. Okay. Now let's again talk about the list of built-in report that we have in playright. So we have list default terminal output. Okay. This will give the default output for each and every test case that you have executed. Then dot minimum dot for the first output. Okay, this will give you the limited information into the report. But this will give you the detailed report, the list view. Then line, if you want to see the line by line progress, you can use
13:58 the line reporter. Then HTML reporter, interactive report with some color and some design, you can go with the HTML report. Then JSON report. If you want to make it machine readable format or when you generate the JSON report right most of the time you normally represent in a different way then you can generate the JSON report. Then the JUnit report again the XML format report for CI/CD tool you can also use that particular things as well. So suppose in interview they might be ask you what are the available built-in reporter in gen uh sorry in playright. So what you can do you can says list dot line HTML JSON and JUnit. These are the six type of reporters that available in a playright as a building.
14:44 Okay. Now there are customized report you can also install like report that we all know right we have used in selenium as well. So suppose you want to integrate the alo report with the playright. What you can do? You can simply install the LIO report by using this command. npm install - lure playrite and once you install that one just configure like your playright doconfigure.ts file like this way reporter LO report and HTML just add report. So it will start generating the lure report as well. And once I once you execute your test case, you need to just put this command npx lure generate and uh lure your result over here. You need to store your result dot- then output on this particular folder and then you can just says npx lure open
15:32 and just click show that folder. It will open that particular report as well for you. Okay. So these three command will help you to work with the LO report with the play uh right. Okay. So these are the different reports and this is how you can generate in a playright. Let's go to the next question. What is await and sync in playright syntax? Okay. Now I know I have seen this questions many times in interview like we when you apply for a Java or selenium initially they will ask you to explain the selenium syntax right the same way they will ask you to explain these two keywords in this particular uh I will just say the syntax of the play right. So let me tell you the await keyword and insynchronize syntax are
16:17 essential to handle the auto wait I will just says the action that take time right like navigation action clicking action typing action waiting for some elements. So those kind of the actions when we want to wait for certain amount of time like that is the concept of auto waiting in play right we need to include that await command in await keyword in each and every line and when you define right when you make your function as a sync then and then you can use await if you do not provide this one a sync then you cannot use await it will throw the error to you so that is the one things because in playright most of the operation are a synchronous and you need to use a wait with them. You need to wait for one actions to be finished then
17:05 you can run the next action. Okay. If you do not use a syn or a weight what will be happen then it will be throw you the common exceptions right it will says element not found navigation not completed some few of the browser related action fail. So to avoid those things, it's always a recommend and always a good practice to use a sync and await keywords when you write the playright test cases. Okay, then let's go to the next questions. What is playright fixtures? Okay, so fixtures that means something already fixed. Okay. So what you can do if you remember in selenium right we have a web driver from using the web driver we use the driver uh instance right and we run through our test we write our test
17:50 cases. So similar way the highlight you see over here after a sync you will see in a curly bracket this is the page this is the one one of the I will just say in my term it's object and using the page it will create the new page for your automation and using that particular page you can use all the methods in the playright like go to then click then type and all those things. So what we'll do this is this is considered as a one fixture in a player right and it will create a new page automatically and inject in your test case. So it will create the object automatically and using this one you can run all the methods. So fixture is a setup and uh fixture is a setup and tear down mechanism used to prepare the resource for your automation. Okay, it will set
18:37 up and at the end of the t uh test it will tear down as well means it will destroy your uh resource as well like a browser pages test data login session and all those things right so that's why fixer is very much important so always when you run your work on a test case on preide always go with this fixtures okay this will help you there are other built-in fixture in pride like browsers that share the browser instance means it will be uniquely create the browser for that particular page instance only. Okay. So you can maintain the cookies and all other information easily. Then context new browser contact like incognito window we have right. So this is the context. Then page new tab inside the context. So once you will create a
19:23 context you need to create a page as well. So that will create a new tab where you can do your web automation steps. Okay. Then the test info that will be related with the metadata information you want to pass to your current test. Okay. And some of the key things why fixtures are useful. Okay. To avoid the repetition of setup code like you don't need to write login and uh like login and all those things um multiple times right if you want to do the API mocking or API I will just say the duplicate API you want to make you can use the fixtures. Okay. Automatically clean up the test after execution. Then better structure and readability. It will give you the better structure. Once you will have your this particular sync then it will give you
20:08 the better readability of the test cases and share the reusable data and resource across the test. Then using the fixer right you can generate the some custom method and those method you can use across the your test automation framework. Okay. So if some if they will ask you this is the common questions that I have seen what is playright fixture and why you required and what are the different play fixture we have you can answer from this slide that will be help you to crack the interview let's go to the next uh question what is the difference between npm and npx so most of the times as a non-developer as an automation engineer we do not concern about those things okay but it's always good to know the basic okay not in
20:54 detail but you should know what is npm stand for what is npx what is a key activity they do okay so npm that means node package manager and it is mainly used to download and manage the libraries or tool okay so npm is a node package manager which used to download and manage the library or a tools it download the package save it on a node modules and add the package in add the package whatever package that you have mentioned in package.json it will save those information. Okay. And node package in executor execute means it will execute your or it will run your NodeJS tools or script directly without installing them globally. Okay. So download the playright command line
21:41 temporarily. You can use that npx execute the install command clean up after the executions. Those kind of activities you can do using the npx. I have put these tables that I found on the internet. You can also use this one when you answer your interview questions. Okay, this will also helpful. What is the example? What is a common use command type package manager? This is the package runner or package executor. You can also say okay. So this is the question. This is the things you should remember when you are working the tool like Cypress or playrite or something like that. Okay, let's jump to the next question. Benefit of cross browser testing. This is not related to specific to the playright but this is related to the overall automation. What are the benefits that we have for the
22:28 cross browser testing? But why I included in this particular things I have also created other interview questions series as well for Java for common automation. But over here because we going to see how playright make cross browser testing easy for us. Okay. And that's why I included over here. So the cross browser testing if you are not aware if you're a fresher and watching this video let me give you the brief of that. The cross browser testing is your that means you are testing your web application across the different browser different devices and different operating systems. So you are testing your SAM test case on window chrome and on Linux on other like the on Mac, Apple or you can Safari browser or anywhere
23:13 you are testing your same test case on a different browser and a different devices. Okay. And why what are the benefit and as them as as it suggests right it we already know okay it will always beneficial to check your application is running fine across the different browser and device okay so it ensure the consistent user experience okay because most of the our web based application will use HTML CSS JavaScript and those kind of the I will just the languages to make look and feel of the application but the browsers that we have right may not adopt those particular design or CSS effect in the same pattern or same way. So we can see sometimes it's work fine on chrome but it is not showing the correctly on
23:59 Firefox or Microsoft age or Safari browser. So those kind of the inconsistency of font mismatch broken UI element then layout not looks good and all those things for that one we need to use cross browser testing and we need to perform the cross browser testing to ensure the consistent user experience then detect the browser specific bugs okay so as I told you right some of the things do not work on Chrome and on some of the things do not work on Safari so those kind of the browser specific issues we can identify using the cross browser testing Again it will save the time and resource. Exactly. So what will happen? Let's suppose I am the one QA tester right and I'm going to test the same functionality on Chrome for 1 hour and from Firefox on
24:47 second hour and then on a Safari for third hour. So the SAM test case I I put my 3 hours effort to do the testing. But using the cross browser testing in automation what we will do within that specific 1 hour time frame we can test the same functionality in a three different browser and we can see the report that's why it says it saves times and resource boost the regression confidence right so exactly when you are a QA right and when you want to go uh when you want to give good to go to your project management team and you know your test case has been executed across the all the browser that will give you the confidence And that will give you the shortity about that your application is working fine or not. Okay. Improve
25:32 the app quality and reliability. So when you have a better applications without bug or without issues that will definitely the benchmark on your quality right and that will help and that that application will be make for the end user like the reliable application and they they are trust on you to use that application without any any issues and all those things. Okay. And using the cross browser testing you can reduce the post release hotpix cost. Okay. So what will happen if you do not do the proper cross browser testing then when you release your application to your end user right and and your end user are using different browsers. So what they will do they will they will start raising the tickets they will start raising the concern to you okay this is something not working on my age browser
26:19 or this is something not working on my chrome browser and those are those kind of the stuffs you will face but if you have already done the cross browser testing then you don't need to worry about those kind of things. Okay. So let's we go to the next things. Okay. How to perform the cross browser testing and it's very simple in I will just say in playright you need to just configure your this code snippet in playright doconfig file you need to give the name of the virtual machines h sorry virtual browsers and your actual browsers like the this way right. So name of the browser chromium will be used for the chrome then firefox then webkit will be mainly used for the safari and all those things. So provide these things three
27:05 things mainly used okay and once you will have this this block configured in your playright config.ts then whatever the test case you execute right it will automatically take this three browser and it will do the cross browser testing automatically. So if they will ask you how you can uh perform the cross browser testing in playright you can just says yes we can configure the project and name and the use of the different browsers in our playright do.config.ts file and based on that we can use we we can configure the uh cross browser testing in playbrite. Okay. So let's go to the next questions how to execute the script in local browser. So if you know right by default when you execute okay
27:54 uh the script it will show you uh it will not display if you just write down npx playright and test and you have not nothing configured in your config file it will start in a headless mode okay it will not show you the execution it will only show the result in a in your terminal but if you want to initiate if you want to show in your like uh the as a local browser right what you can do you can use this headed This is also considered as headed mode. But again which browser it need to take it will take from the config file. So you need to update your config file for the defa def defined config like this way and you can use headless is false means always run in a local headed mode and browser name chromium for chrome. Firefox if you
28:40 want to default to firefox local browser you can put it firefox or webkit. So this this code snippet you need to put in your playright.config.ts file and that will help you to initiate your script in the local browser whatever you have selected. Okay. So the two way use the headed in your I will just say is in your command line when you execute the test or set headless is equal to false. So headless is equal to false means always run in a local mode. Okay. So these are the two way you can execute your script in a local browser in playrite. So so far guys we have covered 10 questions. I know there are many other questions are also coming in this particular series. I'm going to make at least 10 parts with 100
29:26 questions. So please if you like this video subscribe to my channel and hit the bell icon. And if you think some of the questions that are not included then put in a comment box. I will definitely try to include in our upcoming videos of playright interview question and answer series. Thank you for watching.