Automate Complex API Tests with Just One Command 🤯 | Playwright MCP

Brief Summary

This video demonstrates how to use Execute Automation's Playwright MCP server to automate complex API testing, including authentication. It covers the new features in version 1.0.6, such as file uploading and improved text parsing. The video shows how to test APIs with authentication using a swagger.json schema and AI-refined prompts, highlighting the server's ability to perform comprehensive API tests and generate detailed reports.

  • Automate complex API testing with Playwright MCP server.
  • Utilize swagger.json schema for comprehensive API testing.
  • Refine prompts with AI for better test execution.
  • Generate detailed test reports.

Introduction to Playwright MCP Server for API Automation

The video introduces the use of Execute Automation's Playwright MCP server for automating complex APIs, contrasting it with simpler API testing methods demonstrated in earlier videos. The new release of the Playwright MCP server, version 1.0.6, includes features like file uploading, improved visible text parsing with character limits, updated hover functionality, and enhanced browser support. The demonstration focuses on the complex API testing feature.

Exploring the EA API Swagger Documentation

The video explores the EA API, accessible via EA API.somi.com/swagger/index.html, which includes both GraphQL and REST endpoints. It demonstrates the API's authentication process and capabilities for creating, deleting, and managing products. The initial attempt to access a product endpoint results in an unauthorized exception, highlighting the need for a bearer token in the header for authentication. The authentication API is used to obtain a bearer token by providing a username (Karthik) and password (123456). This token is then used to authorize subsequent API calls, allowing successful retrieval of product details.

Setting Up Playwright MCP Server

The video guides viewers on downloading and installing the Execute Automation's Playwright MCP server, referencing previous videos for detailed instructions. It explains how to configure the cloud desktop to run the Playwright MCP server, ensuring it is up and running. The latest version, 1.0.6, is highlighted as the version to use for the demonstrated functionalities.

Automating API Testing with AI-Refined Prompts

The video details the process of automating API testing using the Playwright MCP server and AI-refined prompts. The swagger.json file URL, which serves as the schema for the entire API, is copied. An initial prompt is created to instruct the AI to understand the swagger documentation, perform authentication, and conduct API tests for all endpoints in the schema. The initial prompt is refined using Gemini to improve clarity and comprehensiveness, resulting in a more descriptive prompt that includes instructions for authentication and testing all available endpoints.

Executing API Tests and Analyzing Results

The refined prompt is executed within the cloud desktop environment, where the Playwright MCP server is configured. The server fetches the swagger documentation, authenticates, and begins testing various endpoints. The process involves multiple playright_get tool calls to perform get operations and post operations to obtain the bearer token. The video shows how the server adapts to unauthorized exceptions by including the bearer token in subsequent requests. A comprehensive report summary is generated, detailing the status of each endpoint.

Refining Prompts for Accurate Testing

A new chat is initiated to refine the prompt further, specifically instructing the AI to include the bearer token in the header for all requests. The updated prompt ensures that the authentication token is correctly passed, leading to successful test executions across all endpoints. The video concludes by highlighting the power of using Execute Automation's Playwright MCP server in conjunction with AI models to automate and enhance API testing, making it accessible even for complex APIs hosted in various environments.

Summarize any YouTube video in seconds

Get summaries like this one for any video, in your language, with the free Summ app.

Download on the Apple Store
Get it on Google Play

Transcript

Full transcript of “Automate Complex API Tests with Just One Command 🤯 | Playwright MCP”. Click a timestamp to open the video at that moment. Need another video? Use the YouTube transcript generator.

0:00 Hi guys, welcome back and today in this video we'll be talking about how we can make use of the Exel Automations Playright MCP server to automate the complex APIs instead of just automating the easiest APIs that we were seeing in our other videos in automations YouTube channel before. So if you have noticed that in our earlier videos I talked about how you can do the API test using a simple publicly available APIs and which you can use to perform the API test without having any authentication in place. But now with the new release of playrights exel automation MCP server you can do that much much easily. So if you just go to the github.com/ismission playrightmc server over here and if you just go to the documentation you can see that we have got a new release this time

0:47 with the version 1.0.6 six which has got many new feature and you can see that we have the ability to upload the files and also you can uh you can also get the uh visible text more accurately and also you can get the visible text with a character limits that you can set while you try to parse from a page and also you can now have an updated uh playright hover functionality in the in the interaction tools and there are even more support like browser supports being added which is going use your installed browser instead of just using the browser which is already uh something going to be downloaded by the playright. So those things are covered in this particular version. So I'm going to quickly show you the complex API testing feature at least in this particular video and I'll also show how you can

1:33 make use of the play exo automation MCP server to perform even more things. So just to jump over to our um APIs of our application you can see that we have got a new URL called as EA api.somi.com/swagger/index somi.com/swagger/index.html. This is pretty much like the EA app.somi.com which has got the uh the UI application but this time we have got the API which is going to be the EA API.somi.com right? So you just you can just head over to this particular domain and then you can start uh working with the API. So this is the application which has got uh both the graphql endpoint as well as the rest uh endpoint which is going to give you how you can uh authenticate uh or how you can perform an uh API test

2:19 with the authentications uh and how you can ensure that the APIs can be u can be creating a products and also deleting a products and things of that nature. So it has got all of these over here. So I quickly show you what is going to happen if I just going to uh show you in a nutshell. So if you're just going to go to the products endpoint over here do a try out and if I try to enter the product uh ID as one and if I hit execute you are going to get an unauthorized exception because this particular application do needs you to have an beer token uh in the header uh if not the authentication is not going to happen. So how do you do the authentication? So we have got an authenticate API which is going to do that for you. So you just have to do a uh try out over here. And for the

3:04 username, you just have to use Karthik. And for the password, you just have to use 1 2 3 4 5 6. Uh and if I try to execute this, this is going to give you an uh beer token over here. You just copy this beer token and go to the authorize in the value. Just type uh beer and then copied uh token. You can just paste it over here. Authorize it. That's it. This is going to authorize. And now moving forward, you can just go to the same product which was giving you the unauthorized exception before. And if you try to execute this, it is going to give you the product this time. So simple, right? So you can see that this product has got a name, keyboard, description, price and components are these and this is a product type. So this is what the functionality of this

3:51 particular APIs are. You can use the same thing for getting a product by its name uh and its ID. And you can also get the product by name if you wanted to. Uh and if you want to get the product like all the products, you can get all the products as you can see over here. And if you want to get all the components, you can get it as well if I'm not wrong. So if I just going to go up a bit, you see that get all the components. And if I hit execute, you can get all the different components which are associated in turn with the products. So this is what is this particular API portal is all about and now we're going to see how we can make use of the playright MCP server from his automation to do the API testing. So in order to do that I'm going to go and just download the uh playright MCP server of his automation and then install it in my

4:37 cloud desktop uh over there. If you have not really watched my other videos so please go ahead and do that. This is the way that you can actually do it. So if you just go a bit down over here, you just have to add this particular setting within your cloud desktop configuration and then you can easily do that. So if you have not seen that before, if I'm just going to go over here, this is the cloud desktop that I have already installed. Just go to these settings over here and just opens up here. And if I go to the developer, see that the playright MCP server is currently up and running for me over here, which is using the same thing that I'm showing you over there. Right? That's what I have uh configured it. uh and then once it is there you can then start using it. So the latest version uh well at the time of this particular video recording is going to be 1.0.6 as I just told you

5:24 which is uh this one as you can see over here. So you can start using it and this is quite amazing that you can just use everything from there. So in order to start automating this entire API like not just one API but entire API that we have got in this uh in this particular endpoint over here. I'm just going to go to this swagger.json file because this is like a schema for this entire API that we have got on this particular uh URL. So I'm going to go copy this particular uh schema URL. So this is the swagger json URL which is the schema to be honest and I'm going to say understand the uh swagger documentation uh and perform the uh authentication uh

6:12 perform the sorry API oops API test for all the end points in the schema. See that's what I'm saying. uh the swagger documentation uh link is this and I'm going to say because this site is um is uh going to have an authentication in place. You need to call the endpoint. So I'm just going to go and just help a bit uh our our AI uh to say that you have to call this particular endpoint uh which

6:59 is going to which is going to uh authenticate you right endpoint this one uh with the body as this one right with uh body sorry body as this um and pass this um token with uh be error and then the uh token obtained, right? Token obtained in the header. Or maybe you don't even have to pass this. Uh but this is going to do a bit of a try before it's going to do that. If you don't pass it, it's still going to work, right? I'm going to copy this entire thing right now. And guess what? I'm going to go to uh

7:46 gemini.google.com over here. And I'm going to ask it to refine this prompt for me a bit. So refine uh refine this prompt for me a bit. Uh and I'm going to hit enter. So now what's going to happen is the Gemini is going to go and refine this entire prompt for me. Uh and then it's going to give me things over here. Uh look at that. It's going to say that there are three options. Please test all the API described in this walker documentation. Before testing authenticate by calling this one with a body as this. See this is pretty much exactly the same than what I passed but here it's more descriptive and this guy is even more descriptive than what I have uh given. It's also saying that once authenticated please execute the test against all the available endpoints in the schema. I would appreciate uh a

8:33 report on the status of each endpoint noting any issues encountered. H this is pretty good. I'm going to copy this options. See that I'm just using the power of AI to uh use AI. Uh and I'm going to paste that guy over here. And you see that within our uh cloud desktop I have also configured the playright MCP server which means I can now use this guy to perform the API test for me and now I'm going to hit enter or run and you will notice that this guy is going to start doing it. So it's going to first fetch the swagger documentation and look at that it has read all the swagger documentation for me. Uh and it is the swagger that we have got and it's calling the playright MCP server for me. See that it is navigating to this bigger website and it's getting all the visible

9:20 text which means it has got the schema and now it is going to perform the uh the post operation to get the um to get the beer token for me. Look at that. And now it has did the authentication for me. And now you also notice that on the right hand side it is doing these many tests for me. Look at that. This is amazing guys. You can see that now the status is testing over there and it's also doing all sort of testing for me by doing so many different playright_get tool call. So because we have got so many different tools within our playright mcp server over here and one such tool to perform the get operation is the playright_get uh which is this one if I'm not wrong uh

10:06 as you can see over here this one this is what is being called and if it's a post operation then it's going to do a post over there and because it's doing so many different get it has got an unauthorized exception there now it realized that I need to pass the uh beer token so now it is passing the beer token over here and because I did not tell to pass the beer token along with the beer uh keyword. So now it is trying to pass the beer as well if I'm not wrong. So let's see uh what it has done this time. Uh yeah, I think it has success successfully um uh got the spirit token and it has passed it over there and see uh over here it is trying to do that all the end points like one

10:51 by one it is going through drilling down based on the endpoints that we have got uh in the swagger documentation and it is trying to do that and see that now it is doing a comprehensive report summary updation. Oh, look at that. That is the magic of this this guy for us over here. It's deleting all the existing old test report. And now it is adding all of these for us over here, which is amazing. So all the get and the post and everything is successful. But for some reason the product controller is not working as expected. uh and maybe it is going to go and update that as well and it is going to work as expected for us over here. So just let's wait for this

11:37 every operation to happen. There we go. And look at that. Uh it is saying that it has completed all of these but these products controller for some reason uh is not working for it. uh uh while it is trying to pass this entire thing for me over there and it says that the JWT token authentication broken the token obtained from the login doesn't work for the protected endpoints and there is a insec inconsistent security mode um for the components are public while the product requires authentication. So which means there is some missing gaps in my controller that can be accessible even without having to have a uh a authentication in place over there and then it is trying to do all of these and you see that the test has got passed and

12:23 failed. That's the reason why I was saying that if we pass the beer uh and then the token format then it could even able to understand that. So what I'm going to do is I'm going to maybe just do a new chat over here. try out one more time and over here what I'm going to do is um I can probably say that uh once authenticated please execute the test of against all the available endpoints in the schema uh something like this and I would appreciate a report which is coming up over here right so this is pretty cool that I can uh probably mention that and I'm also going to say that once authenticated please execute the test against all the available endpoints in the schema uh with uh bypassing the header as uh be error uh and then

13:10 the uh then the token uh which is obtained from the uh login endpoint something like that right so this is what I really wanted to uh wanted this to happen this time and if I now try to run this code or this particular prompt this time so let's see what's really going to happen so it's going to go fetch the swagger for us over here. I think it's going to do that pretty good. Uh and now it is going to do a navigate and then it's going to go get the visible text. It has got the complete API structures and then it is going to do the authentication by getting the token. Uh and then it is going to do the test for all the endpoints. Look at that. So because it did the post this time uh and also it just worked fine without any problem.

13:56 And now it is going to do the exact same thing for us over here. Look at that. It's just putting all the uh testing status and then it is going to do the execution for us over here. So this is how you can see that we could able to perform all the different APIs like all the complex APIs to be tested using the uh using the exit automations playright MCP server and also with the power of the new models like sonet 4. It is now trying to enhance and leverage the power even further and the new features that I have released in the Israel automation split MCP server is really kicking in and it is trying to do the test for us without any issues over here. So this is the power guys and I think you really like the update and I'm sure that with this you don't even have to do any API

14:42 test. I mean if you have an application and if you have got the APIs which is hosted either within your own machine or maybe if it is hosted in the the public domain you just have to pass these details and then run it up. You will see the exact same result that I'm getting in over here. So this is the prompt that you got to be following while you try to do that. That's it guys. Once again thank you so much for watching this video. Catch you in the next one.

Share

More video summaries