Part 2: Building API Automation Testing Framework in Rest Assured from from Scratch
ฝัง
- เผยแพร่เมื่อ 16 มี.ค. 2023
- #apitesting #restassured #framework
@0:55 Continuing from part I
READING CREATED USER
@1:24 Create test method in "UserTests" class.
@2:37 Call a method from "UserEndPoints" class and pass other method in parameter in it using "This" keyword to use same username
@4:08 Store response in variable and log response in console
@4:38 Validate status code using assertions (correction @5:55)
@6:52 Execute the test
UPDATE USER
@9:15 Create test method.
@9:46 Copy the code from postUser test method into this method.
@10:35 Whichever the data to update we need to copy those Userpayload code.
@11:15 Rename the method to update the data and pass parameters in it using "This" keyword to use same username
@15:15 Log body in console
@15:54 Storing after update response in variable and validate status code using assertions (correction @19:16)
DELETE USER
@16:54 Create test method.
@17:35 Call a method from "UserEndPoints" class for same username using "This" keyword and store response in variable
@18:15 Validate status code using assertions
@23:14 Execute the test
DATA DRIVEN TEST
@24:32 Introduction
@26:19 Create a folder under same project and paste the excel sheet
@26:39 Opening excel sheet
@27:42 Update pom.xml with APACHE POI dependencies
@28:16 Paste the Excel utility file inside Utlities package
@35:25 Paste the Dataprovider file inside Utlities package
CREATE USER
@43:22 Create a class under "Test" package
@47:27 Create test method
@48:11 In test annotation, add priority, refer particular data provider and refer its class.
@50:45 Pass all variables related to user in parameters of test method
@53:36 Create object for POJO class
@54:09 Call all setter methods from POJO class and pass all variables related to user in parameters
@55:00 Call "Create user" method from "UserEndPoints" class, pass object for POJO class in parameter, store response in variable
and validate status code using assertion.
DELETE USER
@56:49 Create test method, in test annotation, add priority, refer particular data provider and refer its class.
@58:29 Pass username variable in parameter of test method
@58:51 Call "deleteuser" method from "UserEndPoints" class and pass username variable in parameter and store response in variable.
@59:24 Validate status code using assertions
@1:00:51 Execute the test
EXTENT REPORTS
@1:04:15 Update pom.xml with extent reports dependency
@1:04:29 Paste the extent reports utility file inside Utlities package
@1:11:52 Create testng.xml from Test package
@1:12:40 Disable data driven testcase in testng.xml
@1:13:20 Add extent reports tag inside testng.xml
@1:14:52 Execute testng.xml
@1:15:19 View reports
LOGGERS
@1:20:23 Add Apache log4j dependencies in pom.xml and update the project
@1:22:20 paste "log4j2.xml" in src/test/resources
@1:24:49 Create variable for logger class in test case class
@1:25:27 Initiate that variable in Beforeclass method for same class
@1:26:29 Adding logging messages in create user method and repeat for remaining methods.
@1:28:59 Execute the test
NOT WORKING WELL
@1:29:57 Change log levels in "log4j2.xml" for debug logs
@1:32:13 Call debug method in Beforeclass method
@1:32:32 Execute the test
Udemy Courses:
Manual Testing+Agile with Jira Tool
► shorturl.at/xNXZ4
Selenium with Java+Cucumber
► shorturl.at/aIKMW
Selenium with Python & PyTest
► shorturl.at/ELW09
Selenium with python using Robot framework
► shorturl.at/bcDPZ
API Testing(Postman, RestAssured & SoapUI)
► shorturl.at/uAWY7
Web & API Automation using Cypress with Javascript
► rb.gy/4uum2n
Playwright with Javascript
► rb.gy/4uum2n
Jmeter-Performance Testing
► rb.gy/ocj7r2
SDET Essencials(Full Stack QA)
► rb.gy/hlnf2v
Appium-Mobile Automation Testing
► rb.gy/wmzv64
Java Collections
► bit.ly/3S66ezE
Python Programming
► urlis.net/gdsfpb0s
Cucumber BDD Framework
► bit.ly/3F7d69r
Protractor with Javascript
► urlis.net/4uddm1qb
TH-cam Playlists:
Manual Testing & Agile
► bit.ly/3ujvaYa
► bit.ly/3OYzxQj
SQL
► bit.ly/3R6XjeG
► bit.ly/3nE0a1s
► bit.ly/3IeKuuJ
linux & Shell Scripting
► bit.ly/3up1Z6a
► bit.ly/3nzvGxx
Java
► bit.ly/3R9QfOs
► bit.ly/3AoRMKM
► bit.ly/3IbTTDn
► bit.ly/3ybXInv
► bit.ly/3yCoHdw
Selenium With Java+Cucumber
► bit.ly/3P2FMm4
► bit.ly/3yhiIt4
► bit.ly/3uokzet
► bit.ly/3a7XIND
► bit.ly/3umN2S9
► bit.ly/3aar7GW
► bit.ly/3y9kD2S
► bit.ly/3uhLskn
Python
► bit.ly/3agNgU0
► bit.ly/3NJNnoy
► bit.ly/2CTQ4mR
► bit.ly/3OIYWh1
Selenium With Python,Pytest&Behave
► bit.ly/3OHHoC9
► bit.ly/3IeNLdv
► bit.ly/2J4tPeT
► bit.ly/3ydSkAq
Selenium With Python Using Robert Framework
(Web&API Testing)
► bit.ly/3nUvlpr
► bit.ly/3nUvE3z
GraphQL
► rb.gy/sj3gys
This is the best tutorial of restassured framework with reporting , not only on TH-cam but on the entire internet as I have followed multiple rest assured framework tutorials. Thanks Pawan sir !
My Pleasure
You're Great Sir. We don't have any words praise your work
Thanks
My head is explode for the new knowledge xD Great tutorial :)
I can't find the XLUtility and DataProviders files in the videos. Anyway, I created and executed it successfully.
XLUtility.java==============
package api.utilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XLUtility {
public FileInputStream fi;
public FileOutputStream fo;
public XSSFWorkbook workbook;
public XSSFSheet sheet;
public XSSFRow row;
public XSSFCell cell;
public CellStyle style;
String path;
public XLUtility(String path)
{
this.path=path;
}
public int getRowCount(String sheetName) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
int rowcount=sheet.getLastRowNum();
workbook.close();
fi.close();
return rowcount;
}
public int getCellCount(String sheetName,int rownum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
int cellcount=row.getLastCellNum();
workbook.close();
fi.close();
return cellcount;
}
public String getCellData(String sheetName,int rownum,int colnum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
cell=row.getCell(colnum);
DataFormatter formatter = new DataFormatter();
String data;
try {
data=formatter.formatCellValue(cell);
}
catch(Exception e)
{
data="";
}
workbook.close();
fi.close();
return data;
}
public void setCellData(String sheetName,int rownum,int colnum,String data) throws IOException
{
File xlfile=new File(path);
if(!xlfile.exists())
{
workbook=new XSSFWorkbook();
fo=new FileOutputStream(path);
workbook.write(fo);
}
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
if(workbook.getSheetIndex(sheetName)==-1)
workbook.createSheet(sheetName);
sheet=workbook.getSheet(sheetName);
if(sheet.getRow(rownum)==null)
sheet.createRow(rownum);
row=sheet.getRow(rownum);
cell=row.createCell(colnum);
cell.setCellValue(data);
fo=new FileOutputStream(path);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
}
Dataproviders.java=================
package api.utilities;
import java.io.IOException;
import org.testng.annotations.DataProvider;
public class Dataproviders {
@DataProvider(name="Data")
public String[][] getAllData() throws IOException
{
String path=System.getProperty("user.dir")+"//testData//Userdata.xlsx";
XLUtility xl=new XLUtility(path);
int rownum=xl.getRowCount("Sheet1");
int colcount=xl.getCellCount("Sheet1",1);
String apidata[][]=new String[rownum][colcount];
for(int i=1;i
Can you please help me
I got an error on the method "public String[] getUserNames() throws IOException", it's show explains like this "Data provider must return Object[][] or Iterator " can anyone help me?
Thank you so much!
Thankyou so much..
Thanks. did you manage to get the extent report utility code as well? If so, please can you share. Thanks in advance.
Thanks for giving us precious knowledge for free, Excellent explanation
Welcome
Thank you Mr Pavan, excellent as usual!!!
Welcome
Sir you are giving best knowledge free of cost. Thanks its so much useful, could u please add the extentReporter class and log4j.xml files here?
Precious knowledge for free
Thanks
In POST request test data is not updated, It shows previous data only. Guys any one notice that Please check once
good job bro
Mr. Pavan, In the web service method I tested, it creates the Id value itself and returns it as a response. I want to save this value to Excel and use it in my next test scenario. How can I do this according to your structure?
can we use scenario outline?? instead of DDT
Pavan sir, if we have more columns in the excel sheet, is there any approach other than sending arguments in the DDTest class methods?
if you have more columns in the Excel sheet and you want to pass multiple values to your test methods, you can create custom objects or use a more complex data structure to represent the data from each row.
I couldn't find the XLUtility file. So I paused the video and typed the whole thing, lol.
Same for DataProviders. Also the @DataProvider (name="Data") annotation isn't working for me, had to comment it out so far
Me to, good for practice anyway. 🙂
I faced the same issue, how does it magically appear for him 😀
I have a question, what happend if we put the information in the body with no data like we send in the format Json. For example when we send a body usually we put like this:
{
"name" : "name",
"last_name" : "lastname"
}
But when you send the body you don't specifye ("name", getName) so, thats means the programs took the data in order so, if a put getLastname in "userPayload.setFirstName(faker.name().lastName());
The program post like this
{
"name" : "lastname",
"lastname" : "lastname"
}
I don't know if a explaind my self. Because if we don't send information in order that's mean the program took whatever you put in that order
informative and easy to understand. thank you, can you provide bitbucket link of this code if any.
Pls help me someone... I'm using eclipse latest version and java 17 ... I'm not able to get the response....their is no mistake in code I'm following as it is pavan sir... So kindly suggest me the supported software versions
When run the test it is throwing error although code what sir has showed is same. Do we need to do anything?
Mr. Pavan , great tutorial on building api infrastructure , where can we download this code from ? please provide a link , thanks
this API framework series is awesome
I want learn n create framework for testing web application using Selenium+java could you please share link for the same
so that I can answer folder structure n framework related interview questions.
can you please share the data-provider and excel class file?
What about negative scenarios?
Hi! Where can I find the files for this project? Thanks!
Sir where did you get extent file scripts?
Thanks a lot for this very useful series. But where are the files that you said you will share, like log4j, XlUtility etc ?
get it from comments
extend report is not generated sir in folders?
Hi sir..Thanks for the excellent videos!Extent Report is not getting generated in folder..Anybody faced this issue?
Part 3 when it will be available please
Hello @pavan sir where we can get this utility files
sir when i run UserTests it fails & give error ----- FAILED: testUpdateUserByName
java.lang.AssertionError: expected [200] but found [301],seems like endpoints not working
Same for me how do you resolve
Sir where do we find the documents and the XMLs of this API course class?
I have run the script and its failed. continuously getting "405 Not Allowed" error. can someone help in this.
@0:55 Continuing from part I
READING CREATED USER
@1:24 Create test method in "UserTests" class.
@2:37 Call a method from "UserEndPoints" class and pass other method in parameter in it using "This" keyword to use same username
@4:08 Store response in variable and log response in console
@4:38 Validate status code using assertions (correction @5:55)
@6:52 Execute the test
UPDATE USER
@9:15 Create test method.
@9:46 Copy the code from postUser test method into this method.
@10:35 Whichever the data to update we need to copy those Userpayload code.
@11:15 Rename the method to update the data and pass parameters in it using "This" keyword to use same username
@15:15 Log body in console
@15:54 Storing after update response in variable and validate status code using assertions (correction @19:16)
DELETE USER
@16:54 Create test method.
@17:35 Call a method from "UserEndPoints" class for same username using "This" keyword and store response in variable
@18:15 Validate status code using assertions
@23:14 Execute the test
DATA DRIVEN TEST
@24:32 Introduction
@26:19 Create a folder under same project and paste the excel sheet
@26:39 Opening excel sheet
@27:42 Update pom.xml with APACHE POI dependencies
@28:16 Paste the Excel utility file inside Utlities package
@35:25 Paste the Dataprovider file inside Utlities package
CREATE USER
@43:22 Create a class under "Test" package
@47:27 Create test method
@48:11 In test annotation, add priority, refer particular data provider and refer its class.
@50:45 Pass all variables related to user in parameters of test method
@53:36 Create object for POJO class
@54:09 Call all setter methods from POJO class and pass all variables related to user in parameters
@55:00 Call "Create user" method from "UserEndPoints" class, pass object for POJO class in parameter, store response in variable
and validate status code using assertion.
DELETE USER
@56:49 Create test method, in test annotation, add priority, refer particular data provider and refer its class.
@58:29 Pass username variable in parameter of test method
@58:51 Call "deleteuser" method from "UserEndPoints" class and pass username variable in parameter and store response in variable.
@59:24 Validate status code using assertions
@1:00:51 Execute the test
EXTENT REPORTS
@1:04:15 Update pom.xml with extent reports dependency
@1:04:29 Paste the extent reports utility file inside Utlities package
@1:11:52 Create testng.xml from Test package
@1:12:40 Disable data driven testcase in testng.xml
@1:13:20 Add extent reports tag inside testng.xml
@1:14:52 Execute testng.xml
@1:15:19 View reports
LOGGERS
@1:20:23 Add Apache log4j dependencies in pom.xml and update the project
@1:22:20 paste "log4j2.xml" in src/test/resources
@1:24:49 Create variable for logger class in test case class
@1:25:27 Initiate that variable in Beforeclass method for same class
@1:26:29 Adding logging messages in create user method and repeat for remaining methods.
@1:28:59 Execute the test
NOT WORKING WELL
@1:29:57 Change log levels in "log4j2.xml" for debug logs
@1:32:13 Call debug method in Beforeclass method
@1:32:32 Execute the test
Thanks bro, god bless you
For me testcase method is running but its not generating data...could anyone please help me
Hi all! Did anybody face any issues on getUserByUserName test? on my side it is failing with 404: User not found, even though I have done everything as in the video
Same error I am also facing.
Did you got the solution?
Because you have to create a user first before finding it!
I am also facing the same issue and I noticed that user is not created when you call post user method.
{
"code": 200,
"type": "unknown",
"message": "1950701640"
}
Ig its coz of authorisation
As it can only be done by logged in user
@@thundergaming1920 Hey bro
did you get the solution for that?
sir plz, it is any issue firstname and last name not generated (not showing in output)other id,email,phone number and password generated(showing)
Where i can get the XL Utility file.
@SDET- QA Automation Techie
I'm using Mac with IntelliJIDEA., I'm doing everything very perfect as like in this video., but the aventstack extent report is not generated for me inside the reports folder as soon as the test is completed., but however the same code works fine for me in windows (with Same IntellijIDEA).., I've also enable R&W permission for the reports folder in Mac., but it's not worked out., Kindly help me out., Also pls if any of you knows the solution., kindly help me out
unix takes forward slashes instead. try:
sparkReporter = new ExtentSparkReporter(".//reports//" + repName);
Sir I want to join your session how I can join please suggest
Is this project available in Git??
sir please provide git link or code utilised in video link for practice purpose it will be very useful
public static String get_url = base_url+"/user/{username}"; - Not working not passing the name exactly
Yes me also getting same error
Hi bro
did you get the solution for that?
if yes, then how to solve that
Sir can you make similar api automation video using python n pytest
Very good Tutorial. How can we get the code? is there any github code repo? Thanks
is the base URL changed or path param definition changed? anyone please let me know
Could you make videos API automation with python full course
Thanks in advance
Hello sir Can you provide utilities file , Data provider file ,Dataprovider access file file, apache poi class file
Pavan, if u don't mind, oculd u please share the data provider file and excel utility file in this chat.
sir can u provide github link for this project.
Hi, Can you upload the final project with the code here?
Can any one, please share me the ExtentReportManager class
firstname and lastname not showing in output
where can i find please help me
Can anyone provide the Extent Report class file
Hi Anyone provide me the extent report manager class file
Sir please share the XML file in description
Hi Sir
I have asked multiple time for course content/files/documents but did not get reply from you
please provide all pdf and docs related postman and Rest assured course or upload
It's really help for me and others also
please provide your reply/comment
Hello Sir, where can I get the ExcelUtility.java file?
where can i find utility file?
have you XL utility and data provider file ? if yes please share with me
Anyone have github link for this project please share it
@pavansdet Could you share XLutility file here
sir can you please share the utility code
?
package api.utilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XUtility {
public FileInputStream fi;
public FileOutputStream fo;
public XSSFWorkbook workbook;
public XSSFSheet sheet;
public XSSFRow row;
public XSSFCell cell;
public CellStyle style;
String path;
public XUtility(String path)
{
this.path=path;
}
public int getRowCount(String sheetName)throws IOException
{
fi = new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
int rowcount=sheet.getLastRowNum();
workbook.close();
fi.close();
return rowcount;
}
public int getCellCount(String sheetName,int rownum)throws IOException
{
fi=new FileInputStream(path);
workbook =new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
int cellcount=row.getLastCellNum();
workbook.close();
return cellcount;
}
public String getCellData(String sheetName, int rownum, int colnum)throws IOException
{
fi =new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
cell=row.getCell(colnum);
DataFormatter formatter =new DataFormatter();
String data;
try {
data=formatter.formatCellValue(cell);
}
catch(Exception e)
{
data="";
}
workbook.close();
fi.close();
return data;
}
public void setCellData(String sheetName, int rownum, int colnum, String data) throws IOException
{
File xlfile=new File(path);
if(!xlfile.exists()) // If file not exists then create new file
{
workbook=new XSSFWorkbook();
fo=new FileOutputStream(path);
workbook.write(fo);
}
fi=new FileInputStream(path);
workbook=new XSSFWorkbook (fi);
if(workbook.getSheetIndex (sheetName)==-1) // If sheet not exists then create new Sheet workbook.createSheet (sheetName); sheet-workbook.getSheet (sheetName);
workbook.createSheet(sheetName);
sheet=workbook.getSheet(sheetName);
if(sheet.getRow(rownum)==null) // If row not exists then create new Row sheet.createRow(rownum); row-sheet.getRow(rownum);
sheet.createRow(rownum);
row=sheet.getRow(rownum);
cell=row.createCell(colnum);
cell.setCellValue(data);
fo=new FileOutputStream(path);
workbook.write(fo);
fi.close();
fo.close();
}
public void fillGreenColor(String sheetName,int rownum, int colnum)throws IOException{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
cell=row.getCell(colnum);
style=workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREEN.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
public void FillRedColor(String sheetName, int rownum, int colnum) throws IOException
{
fi= new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
cell=row.getCell(colnum);
style=workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.RED.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
}
Sir, please can you share your github link so that I can download this code?
FAILED CONFIGURATION: @BeforeClass api.test.UserTests.setupdata
java.lang.NullPointerException: Cannot invoke "api.payload.User.setId(int)" because "this.userpayload" is null
i got this error after running suit .....i will follow same step as you mentioned
Same here …did uh solve this issue ?
yes
@@sumedhramteke9439
Can we get Utility files sir?
package api.utilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XLUtility {
public FileInputStream fi;
public FileOutputStream fo;
public XSSFWorkbook workbook;
public XSSFSheet sheet;
public XSSFRow row;
public XSSFCell cell;
public CellStyle style;
String path;
public XLUtility(String path) {
this.path = path;
}
public int getRowCount(String sheetName) throws IOException {
fi = new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
sheet = workbook.getSheet(sheetName);
int rowcount = sheet.getLastRowNum();
workbook.close();
fi.close();
return rowcount;
}
public int getCellCount(String sheetName, int rownum) throws IOException {
fi = new FileInputStream(path);
sheet = workbook.getSheet(sheetName);
row = sheet.getRow(rownum);
int cellcount = row.getLastCellNum();
workbook.close();
fi.close();
return cellcount;
}
public String getCellData(String sheetName, int rownum, int colnum) throws IOException {
fi = new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
sheet = workbook.getSheet(sheetName);
row = sheet.getRow(rownum);
cell = row.getCell(colnum);
DataFormatter formatter = new DataFormatter();
String data;
try {
data = formatter.formatCellValue(cell);
} catch (Exception e) {
data = "";
}
workbook.close();
fi.close();
return data;
}
public void setCellData(String sheetName, int rownum, int colnum, String data) throws IOException {
File xlfile = new File(path);
if (!xlfile.exists())// if file not exist create new file
{
workbook = new XSSFWorkbook();
fo = new FileOutputStream(path);
workbook.write(fo);
}
fi = new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
if (workbook.getSheetIndex(sheetName) == -1) // if sheet not exist create new sheet
workbook.createSheet(sheetName);
sheet = workbook.getSheet(sheetName);
if (sheet.getRow(rownum) == null) // if row not exist create new row
sheet.createRow(rownum);
row = sheet.getRow(rownum);
cell = row.createCell(colnum);
cell.setCellValue(data);
fo = new FileOutputStream(path);
workbook.write(fo);
fi.close();
fo.close();
}
public void fillGreencolor(String sheetName, int rownum, int colnum) throws IOException {
fi = new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
sheet = workbook.getSheet(sheetName);
row = sheet.getRow(rownum);
cell = row.getCell(colnum);
style = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.GREEN.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
public void fillRedcolor(String sheetName, int rownum, int colnum) throws IOException {
fi = new FileInputStream(path);
workbook = new XSSFWorkbook(fi);
sheet = workbook.getSheet(sheetName);
row = sheet.getRow(rownum);
cell = row.getCell(colnum);
style = workbook.createCellStyle();
style.setFillForegroundColor(IndexedColors.RED.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
cell.setCellStyle(style);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
}
can someone pls tell me how to get this xlutility file and dataprovider.java file.. i have watched part1 and now in part 2, but how to get the files i dono
package api.utilities;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class XLUtility {
public FileInputStream fi;
public FileOutputStream fo;
public XSSFWorkbook workbook;
public XSSFSheet sheet;
public XSSFRow row;
public XSSFCell cell;
public CellStyle style;
String path;
public XLUtility(String path)
{
this.path=path;
}
public int getRowCount(String sheetName) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
int rowcount=sheet.getLastRowNum();
workbook.close();
fi.close();
return rowcount;
}
public int getCellCount(String sheetName,int rownum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
int cellcount=row.getLastCellNum();
workbook.close();
fi.close();
return cellcount;
}
public String getCellData(String sheetName,int rownum,int colnum) throws IOException
{
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
sheet=workbook.getSheet(sheetName);
row=sheet.getRow(rownum);
cell=row.getCell(colnum);
DataFormatter formatter = new DataFormatter();
String data;
try {
data=formatter.formatCellValue(cell);
}
catch(Exception e)
{
data="";
}
workbook.close();
fi.close();
return data;
}
public void setCellData(String sheetName,int rownum,int colnum,String data) throws IOException
{
File xlfile=new File(path);
if(!xlfile.exists())
{
workbook=new XSSFWorkbook();
fo=new FileOutputStream(path);
workbook.write(fo);
}
fi=new FileInputStream(path);
workbook=new XSSFWorkbook(fi);
if(workbook.getSheetIndex(sheetName)==-1)
workbook.createSheet(sheetName);
sheet=workbook.getSheet(sheetName);
if(sheet.getRow(rownum)==null)
sheet.createRow(rownum);
row=sheet.getRow(rownum);
cell=row.createCell(colnum);
cell.setCellValue(data);
fo=new FileOutputStream(path);
workbook.write(fo);
workbook.close();
fi.close();
fo.close();
}
}
package api.utilities;
import java.io.IOException;
import org.testng.annotations.DataProvider;
public class DataProviders {
@DataProvider(name="Data")
public String[][] getAllData() throws IOException
{
String path=System.getProperty("user.dir")+"//testData//UserData.xlsx";
XLUtility xl=new XLUtility(path);
int rownum=xl.getRowCount("Sheet1");
int colcount=xl.getCellCount("Sheet1",1);
String apidata[][]=new String[rownum][colcount];
for(int i=1;i
Hi Sir,can you share the XLutilitie file sir that would be helpful for us
Hi pavan sir, can u pls give me latest video in github repo link pls sir
Please crete graphql automation using restassured
On Udemy how to get 'selenium with java course by Pavan sir' at offer price
Every now and then after discount, price reduces to 449 Rs. Buy at that time.
@@somashekarkv4845 now the price is 3499/-
@@soniyajabade-qj1zf Keep checking daily, it will reduce to 449 rs within this month
Can you pls share excel utility file
Utility file link?
Did you get the utility file link?
Dear pavan Could you Share with us the Data provider file please
can you share XLUtility file with me
Sir please share Excel Utility file.
while running the file user i am facing the issue
[RemoteTestNG] detected TestNG version 7.4.0
FAILED: f
javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)
can anyone help me for this
Why don't you provide any file
Sir pls provide Log4j2 xml file
log4j2 file
./logs
sir plz, it is any issue firstname and last name not generated (not showing in output)other id,email,phone number and password generated(showing)