hi folks uh welcome to breakpoint 2025 uh this is Sadashukla and uh I am working for Amazon as an SD2 i have around 13 14 years of experience into automation DevOps AWS and currently like everyone else I'm working more on the LLM and AI side right and that's how our today's topic is our today topic is basically related to how we can use the generative AI for creating test automation scripts so for ease of understanding I have divided this session into two section first section is mostly I will walk you through the slides and I have tried to create the slide in a star format so that it would be easy for everyone to understand right so once we are done with the uh slides uh what I will do I will show you a quick demo using some of the code generation tools on how exactly we can generate more uh effective automation scripts right so let's start as I told I have created the slides in a star format so our first thing is situation right so what is the current state of test automation that currently we are um creating the test scripts It may be in uh selenium or playright or cypress or rest assured or request library whatever language you use or whatever library we use right so what we do we basically design our framework and then write the test automation scripts for that what happens sometime uh a framework specific knowledge or skilled QA engineers are required and sometime it also happens like due to lot of work um on taking care of both functional testing and automation we don't even get bandwidth to automate right and we all know right nobody works like your automation and everything is going uh with the same sprint development and automation it never works automation usually goes one sprint behind due to that region right because less bandwidth we have so just to give you a over um example I have written an example over here that if you have a QA team in a in an e-commerce company manual writes UI automation scripts for every new checkout flow in selenium java each script takes 3 to four hours delaying the sprint cycle as I told right because when you are developing manual testing is pretty easy means the functional testing part is pretty easy through manual testing because you can execute it place the order right and then test it but if you go through the automation nowadays we don't have a team structure where you have 10 people for QA five are doing manual five are doing automation nowadays that scenario is not that much active right people are preferring that okay instead of taking 10 QAS we will take five QAs and they will do both the manual and automation in that case writing those automation script takes a lot of bandwidth right first thing second thing sometime if some team member left then hiring another one with the same skill set would be another problem for example in market you will get lot of folks from selenium java but difficult to get typescript with playright right so those kind of problem uh usually happens so what would be the uh required task to be taken over here so the task is like how we can uh basically reduce the effort in writing those test automation script right first thing second thing how we can make sure that changing language should not be a barrier that means if you are in Java if you have to write in JavaScript or TypeScript or Python it should not take that much of time that I'm learning a language and then start writing automation script right and the third uh point would be like how we can make it in a way that uh with the minimal effort we should be able to write more test scripts to put it in an easier way let's assume you are writing initially 100 test scripts in 5 days now or that's a big number maybe 20 test scripts in 5 days then we should find a way where we can write 20 test scripts in one day right without compromising the obviously the standards and thing so how so this is our task right that we have taken now we know that what is the situation what is the task now what action we can take on it so the action is like we should use generative AI LLM models or agentic AI whatever prefers so that the pace at which we are now writing the test script should be multifoded that what does that mean 20 test scripts in 5 days now 20 test scripts in one day so instead of writing the test scripts what we will do we will just give the command or the prompt or the um share our um test cases with uh AI so that it should be able to generate the automation script now your question may be then what the automation test uh engineers will do see it will generate the test script that who will review it who will validate it who will make sure the coverage is right definitely an automation engineer who already has experience in it can only be able to do right for example if selenium java test script is failing if you don't know selenium anyway you will not be able to fix it right that's why it's not like it is replacing us it is like instead of writing 20 test script in 5 days let's write it in one day correct and and you may be thinking like what I will do in the rest four days right so the rest four days you will explore how I can contribute in unit testing correct so this kind of things we I I will discuss about it a bit more that what we will do with that additional time apart from spending with family yeah so that's why what we are going to do we are going to see that how we can use generativebi in a way so that we can generate those test automation script with very less effort right not only that we will also see that how we can write the test automation script review the test automation script using AI and one more thing where most of our automation engineers struggle that whenever you join a new organization they will give you their own framework right and people struggle a lot to understand that what exactly that framework is doing because many framework they don't have the class flow or the functional flow properly designed using a diagram right I'm not talking about mind because those are not my favorites but at least the mermaid or something if you guys are using then those diagrams are not present right and that's a pain point so we will see how we can take help of AI to understand a complete unknown code right and the fourth point we will also see how exactly we can enhance our code optimization and coding standard techniques using generative make sense right folks give a thumbs up okay so the last one is result so what the result we will get we will get reduce script creation time by over 7 how I came uh come with this 70% so I'm working with this since last one year at multiple places i have uh discussed it with my students also and we have seen that the overall reduction is around near about 40 to 50% is frankly speaking so why the 70% comes into picture if we think about the repetitive task boilerplate code then it can easily replace 70% okay but if you're thinking about only generating new test scripts it would be still less than 50 and yeah so the faster onboarding why because if you don't know Python also you can take help of uh AI to basically understand the existing code in Python and then create of your own right yeah some other points I have already written right how it saves time and all some numbers I have already given from my R&D right that one you can refer from this slide but yeah next what we will see we will see that what would be the impact from this and what would be the next step and then the most interesting part the demo right so before we will go into the impact and next step what we should do we should jump into the demo right now okay so I will take you to the ID my favorite ID intellig right let's go to intelligent So here we are with our intelligj so I will first start with one script where I will try to show you how we can basically generate a uh selenium script okay using our uh generative so for generativebi there are multiple ways to do it right one is like you can go to the GPT copy paste right one is like aentki one is like code generation tools right anything you can use uh for this demo purpose I'm using Amazon Q developer which is a code generation tool okay similar to GitHub copilot okay so now let assume I want to generate test script see it has started doing the job so I want to generate a test automation script using Selenium Java where I want to perform some step let's assume I want to perform this generate a selenium test script in Java see you have to very um whenever you write a prompt right assume it you are writing a code command okay so any mistake will give you a very bad kind of code which won't be that useful right i have given some tips around it in our next slide when we go back to our PPT okay so I want to generate a selenium test script in Java for logging into a Gmail account with username and password right so here I can do like with username as maybe example SID okay and password as maybe Krishna or something like that right so uh with username as Sid and password as Krishna right so now the thing is that here also we can give more input right uh if you if you see now what's the difference between a person who knows selenium and a person who is not aware of selenium so if you notice over here let me move it little bit there so that it would be easy for you folks to see so here I haven't written that how it will identify the username and password element right so here we you can mention that okay username ID is maybe USR NE right password element id is pwd let's let assume okay now I am pressing Enter so see now see what it will do can you see folks it is prompting it is giving me command for my entire method that public static void Gmail login webdriver driver is the instance driver.get why it is written xxx because I have not mentioned the gmail what would be the URL for it driver.find element by do ID usr name can you see send case sid pwd case krishna ID login button dot click right super easy correct no need to go through Google Stack Overflow GPD just put it over here it will give there is one more point to notice okay so if you notice over here suggestion one of five so usually it gives multiple suggestion you can walk through it see now here what it has done instead of input parameter to the method it is giving a new webdriver driver line so this is more good driver.quit also if it is adding here it can you see it is more elaborative submit the form verify login this is more better it seems right and then click next okay this looks good to me so I have picked this one so whatever feels like okay this is more realistic pick that one now you can see my entire code is up and ready right folks how long it takes I guess one or two second correct this is this is exactly we this is exactly how the AI is going to help us right so instead of if we have written of our own it would have taken us some time right we have just given the input and it has done done it pretty quickly for us right so now this is one of the best thing I like about a right you can write codes very quickly so similarly you can write for rest issued or you can write for maybe APM for example you want to write for rest issued right let let let's give it a try right uh generate test script for get method/ users and validate status code as 200 using rest assured and TestNG assertion okay add your test logic here that is not promising right let's take the C see it is not able to give us the right prom do you know the region folks let me show you because I don't have imports for rest assured this is one of the most important trick if you don't import the right package it sometime doesn't give the right output for you i'm going to quickly pick a API automation project which I already have right from there I can go to any method which I have already have in this one and then what I'm going to do I'm going to put it over here okay the same exact command that we have used right over there see I will I'm showing you so that you will not make this obvious and uh errors okay so instead of here I am just moving it to my another package where I have rest issued already used now the same exact prompt okay see can you notice folks the difference you got it right so the imports are pretty important if you don't tell it that what imports you have used and all then sometime it doesn't give us the expected code okay see perfect can you notice so you must be thinking how it is coming of this it it may be learning from the old test scripts I already have over here so simply if I will go and create a new Java class and if I try this then it may not add this details this is just learning it from the existing class that's the beauty of it right so I have shown you demo on this two things like how you can generate test case with commands on your IDE right so that it would be easy for you and here also if you want to change something for example if you want to add something see it is already prompting it will also prompt you that if you want to add something you can easily do that like this okay after this I will show you uh we will go back to our slide okay so now we are again back to our PPT where we will learn about the impact and next step so what would be the impact if we start generating scripts like this so for example shift left setting by involving stakeholders earlier make automation inclusive for manual tester yeah and the most important part um we can be much faster in delivering the output right we can at last pace up with the development uh speed to generate our automation script right and at that point we will give better quality more coverage right those are the things will help us to do so now there are come some tips which I have given over here which is super critical folks if you do these mistakes it would be difficult for you to use prompts okay for example be specific with the prompt for example two language and purpose wrong tool write login test this is a very bad thing generate a selenium test kit in Java for logging into website the one I have written right and I've shown in example in this prompt also username and password ID you have missed so as I as we have seen in the demo you we need to mention those things also define input and expected output clearly very very crucial folks okay this one break down complex task don't give a very complex task um in a single line it may not be able to understand it properly for example write a page object model for the login page in playrite typescript right provide context around framework and architecture create a test like this right so those are the important points that you should definitely consider when you start using this prompts and all right now as I promised initially we have just seen the demo how to create the test automation scripts but next what we are going to do is interesting i will show you how you can use this to review your code right to enhance your code right and to make changes on your code too okay so let's jump into our ID quickly so here is our ID let assume I have we have generated this code right uh just let me take back to the ID uh let's go back to our task right so this is the code uh that has been generated for us right if you remember this is the code that has been generated now let us assume you want to review this piece of code right what you can do you can there are multiple ways okay either you can select this code right click on it come to Amazon Q here you will get some points explain the code refactor the code fix the code optimize the code generate unit test for it send to prompt inline chat on this code everything can be done very easily let assume you are a Python guy right you don't know anything or maybe you are a Java guy you don't know anything about play TypeScript then how you will utilize it smartly let assume I will go over here i will take you to a code uh let us assume I go over here into task or let assume you are in Python you don't know Java right and you don't understand what this class or this method is exactly doing what you can do you can select this one right right click on it amazon Q no need to select let's go with the entire class explain code okay just let me move my cursor over here so if you see over here when you just click on the explain code it will explain you everything what is happening over here see how properly it has explained explain the following part of my code for me let me break down the selenium setting up the browser finding the login elements entering the credentials submitting the form verifying the login cleanup awesome right you don't even have to put a lot of brain like where to figure out how I will understand this code whom to ask following up with multiple folks everybody seems too too busy when you joined a new organization right so so that's why this is the best way to understand your code right similarly let assume you want to review your code okay so the commands I have shown you uh by clicking or right clicking that one you can also get it over here by clicking a sl generate code/de if you want to generate documentation for your code you can use uh /doc now let's see that let assume you're working in a project there is no one to review your code then what you can do you can simply use this / review okay review entire project or review the active file we will go and review the active file okay so review active file okay so what it basically does it considered the basic coding standards okay i will also send you a document where I mentioned most important coding standards and optimization techniques which will help you maybe so now what it is basically doing it is basically going through the files right and it is reviewing the code right it will review the code and it will also give you suggestions that what you can do better so that it will be more efficient for you so the increasing the efficiency in terms of coding standards and optimization techniques because many of my students say that okay we don't have a review process so we don't able to learn so this is the best way folks right so let it complete let it review the code right meanwhile let me minimize it and we I will show you a couple of more things there is also one more way where you can see see it has already done reviewing your file view in code issues panel waiting for your inputs okay so it will come over here can you see print rather than a dedicated logging facility see system.out route poor logging practice 100% right poor logging practice again print len it will also show you which line folks see this one is common weakness enumeration lack of exception handling very good very good impressed right and this is also see no potential exception handling and the best part is you can also fix it over here right away okay see can you see the button generate fix can you see see if If you click on generate fix regenerate fix so this is the fix it has suggested that it will use logger and then it will replace with logger apply fix if you click on apply fix it will automatically review your it will automatically remove the this one and it will add it over here see this is the one it has added private definitely you need some fixes logger factory dot table xpath because it has assumed that that is the name correct import class we can import it right folks similarly you can also look into the other fixes see some medium are there some readability and mentability issue performance performance is also if it has figured out something correct you can you can check uh the rest of the things right so those are kind of the examples you can use those are the kind of the um features that you can use while working with aantici your code generation tool right so we have seen how to generate how to review and then how to fix do the fixes also right there is one more aspect of it okay that I'm going to show you right if you put uh left over here there is one more thing I will show you which is which I like a lot okay folks so let me just drag it quickly if you come over here just put slash as I told SL is the best one so you can generate unit test also for it so if you just select this one right and you can Press enter what it will do basically whatever method you have created right it will automatically generate unit test for it okay so table expert Java we have around two method one is main method and one is this Gmail login test so basically it will try to generate test script uh try to generate unit test also for it see generating unit test 0% right so similarly there is one more thing which you can use that is doc generate documentation for your code create a readme file okay see task so create a readme for this project yes this might take a minute so see if you have if you're creating a project and you don't have time to create a proper which is always missing right very rarely I have seen project where people have a good readme so this is where you don't have to put a lot of effort right so now it will create a readme for you it will create the doc and it will review your code it will help you to enhance your code what else we need right okay cool cool folks i hope um you must so it will take some time to generate these things okay see it has created this this is the dock it has created okay can you notice folks no unit test sorry this is the unit test one okay it has generated some unit test over here see table path test it has already generated see this is the unit test it has generated test main method prints Francisco change and then table x path main and then test main page not accessible see if you accept it it is going to create this text path test table path x test see entire unit test it has created isn't it awesome folks right cool man i hope you guys have uh got a little bit of preview how thing works around it right and um this document I'm going to share i hope you have liked the session if you have any queries any doubts you can reach out to me on LinkedIn or you can reach out to me on my YouTube i put all those videos on my YouTube you can check it this is my YouTube channel and my LinkedIn and if you want to connect with me you can reach out to me with through this link okay you can find all my details over here linkree Siddhashukl I have post everything okay all my videos courses trainings everything is over here you can go and check okay hope it has helped folks if you have any more interesting topics do reach out to me and if you have tried any new code generation tool apart from GitHub Copilot or Amazon Q developer do share with the community right till then take care bye-bye