Generating Random String :
As a automation tester,we can come across the various steps to automate,I have come across the following situation:
Requirements :
- Open our application URL (http://www.someurl.com)
- Click on Register -> It open Registration Page
- Fill all the details such as First Name,Last Name,User Name, Email.....etc
- Click on Submit the details
- Verify user created successfully
NOTE : I want to create 100 users
Partial Solution 1 :
- Create a Register method and parameter it as shown in below pic
2. Parameter the test using the external data sheet (TestData.xls),This execl should have all the 100
user's First Name,Last Name,User Name Details
Limitation of Solution 1:
This approach will work pretty good at first iteration,But when i execute the same script multiple times ,I will get the error message as :
This error occurs,because we have used the excel data for previous iteration
Best Solution :
After trying all the possibilities,we have decided to go with the Random Generator,It gives you one unique random string each time it is executed
Steps to use :
- Download the TestUtils.jar from https://drive.google.com/file/d/0B9ZTXXKTZAYVUGZ5d0loWUNhMlk/edit?usp=sharing
- Add it to your Class path
3. Import
the following class in your Test.java
Import
com.webdriver.framework.*;
4. Use any one of the code shown below :
5. Finally my code is looks like below :
Appreciate your comments and suggestions :
NOTE:Thanks to the author of this method and my mentor :Mr.Pankaj Kumar,
good stuff mate
ReplyDeletenice
ReplyDeleteGood Work !
ReplyDelete