Issue with XLSX reports function | Selenium Forum
P
Preetinder Virk Posted on 23/02/2020

Hi,

 

From a video in Module 22 I tried to write steps for createXLSReport() function and executeKeywords() function as below(as in Downloads of the entire code I don't see the same functions):

public void executeKeywords() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, EncryptedDocumentException, IOException {

for (CurrrentTestStepID = 2; CurrrentTestStepID <= ((CurrentTestSuiteXLS

.getRowCount(Constants.TEST_STEPS_SHEET))); CurrrentTestStepID++) {

// checking TCID

if (CurrrentTestCaseName.equals(

CurrentTestSuiteXLS.getCellData(Constants.TEST_STEPS_SHEET, Constants.TCID, CurrrentTestStepID)))

 

{

 

CurrentKeyword = CurrentTestSuiteXLS.getCellData(Constants.TEST_STEPS_SHEET, Constants.TEST_KEYWORDS,

CurrrentTestStepID);

APP_LOGS.debug(CurrentKeyword);

 

 

for (int i = 0; i < meth.length; i++) { //

 

if (meth[i].getName().equals(CurrentKeyword))

 

 

{

 

keyword_exe_result = (String) (meth[i].invoke(keywords));

 

APP_LOGS.debug(keyword_exe_result);

resultSet.add(keyword_exe_result);

}

}

 

}

 

}

 

}

public void createXLSReport() throws EncryptedDocumentException, IOException

{

 

 

  String colName=Constants.RESULT+(CurrentTestDataSetID-1); boolean

  isColexists=false;

  for(int x=0;

  x<(CurrentTestSuiteXLS.getColumnCount(Constants.TEST_STEPS_SHEET)); x++) {

 

  System.out.println(CurrentTestSuiteXLS.getCellData(Constants.

  TEST_STEPS_SHEET, x, 2));

  if(CurrentTestSuiteXLS.getCellData(Constants.TEST_STEPS_SHEET, x,

  1).equals(colName))

  { isColexists=true; break;

  }

  } if(!isColexists)

  {

  CurrentTestSuiteXLS.addColumn(Constants.TEST_STEPS_SHEET, colName); int

  idx=0;

  for(int y=2;

  y<=CurrentTestSuiteXLS.getRowCount(Constants.TEST_STEPS_SHEET); y++)

  {

  if(CurrrentTestCaseName.equals(CurrentTestSuiteXLS.getCellData(Constants.

  TEST_STEPS_SHEET, colName, y)))

  {

  if(resultSet.size()==0)

 

  {CurrentTestSuiteXLS.setCellData(CurrrentTestCaseName, colName, y,

  Constants.KEYWORD_Skip);} else

 

  {CurrentTestSuiteXLS.setCellData(CurrrentTestCaseName, colName, y,

  resultSet.get(y));} }

 

 

 

  } idx++; }

 

 

 

if(resultSet.size()==0)

{

CurrentTestSuiteXLS.setCellData(CurrrentTestCaseName, Constants.RESULT, CurrentTestDataSetID, Constants.KEYWORD_Skip);

 

return;

}

else

{

for(int i=0; i<resultSet.size(); i++)

{

if(!resultSet.get(i).equals(Constants.KEYWORD_Pass))

{

CurrentTestSuiteXLS.setCellData(CurrrentTestCaseName, Constants.RESULT, CurrentTestDataSetID, Constants.KEYWORD_Fail);

return;

}

 

 

 

 

 

}

 

 

}

 

 

CurrentTestSuiteXLS.setCellData(CurrrentTestCaseName, Constants.RESULT, CurrentTestDataSetID, Constants.KEYWORD_Pass);

return;

}

 

}

 

Please inform whats wrong with this code. I am getting only pass as Result in first Suite for a test with Runmode Y. Rest Skip and pass are missing in other 2 suites. Also Result columns are added in Test Steps sheet only for first Suite but not for other suites and also no pass/skip status. Attaching zip file.


A
Ashish Thakur Replied on 24/02/2020

Please share the complet exception stack trace.


P
Preetinder Virk Replied on 24/02/2020

As I said there's no exception and test executes. But I am getting only pass as Result in first Suite for the test with Runmode Y. Rest Skip and pass are missing in other 2 suites. Also Result columns are added in Test Steps sheet only for first Suite but not for other suites and also no pass/skip status. 

I think there's some discrepancy in the 2 functions execute keywords and createxlsreport. I attached the zip file earlier which has the driver script code. Please inform what is incorrect/missing in code.

 

thanks


A
Ashish Thakur Replied on 28/02/2020

As i analyzed your project. It is missing the very basic things. Example, JDK library. POM.xml Content.

I would suggest you to start watching the videos again carefully and then try working with the frameworks.


P
Preetinder Virk Replied on 28/02/2020

Its not missing the JDK file I have JDK 13 but the project required JDK 9 so I downloaded via maven and added it to my pom.xml too. Images are attached. Also starting with watching videos does not help they are the same with createXLSReport() function and executeKeywords() functions that define a keyword driven hybrid approach with ability to paste PASS/SKIP/FAIL status in Reports and also add Results in Test Steps sheet of testcases.

Referring to/writing code displayed in video is very difficult as the screen changes very often while the instructor is explaining. Also downloaded final version of code does not include the 2 functions createXLSReport  and executeKeywords

I have been struggling with this for a long time now so prompt help is appreciated. 

 

Thanks


P
Preetinder Virk Replied on 28/02/2020

Here is Drive link to Screens: https://drive.google.com/file/d/1JqKwI1WL2V7Cw2VNqEev8U_QoKM68xCc/view?usp=sharing


P
Preetinder Virk Replied on 28/02/2020

It wouldn't require much effort to share with me the complete code of Module TRAINING VIDEO - 22 JUNIT AND HYBRID (KEYWORD+DATA) FRAMEWORK with all dependencies and functions as in video. I think then it will be easy for me to go on practicing with later videos too.


A
Ashish Thakur Replied on 02/03/2020

Please look at the sample pom.xml atached below.

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>your.package.name</groupId>
	<artifactId>your project name</artifactId>
	<version>1.0-SNAPSHOT</version>

	<name>HybridFramwork_December2019</name>
	<!-- FIXME change it to the project's website -->
	<url>http://www.example.com</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
	</properties>

	<dependencies>
		<!-- POI -->
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi</artifactId>
			<version>4.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml-schemas</artifactId>
			<version>4.1.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-compress</artifactId>
			<version>1.19</version>
		</dependency>
		<dependency>
			<groupId>org.apache.poi</groupId>
			<artifactId>poi-ooxml</artifactId>
			<version>4.1.1</version>
		</dependency>
		<!-- Selenium -->
		<dependency>
			<groupId>org.seleniumhq.selenium</groupId>
			<artifactId>selenium-java</artifactId>
			<version>3.141.59</version>
		</dependency>
		<!-- Extent Reports -->
		<dependency>
			<groupId>com.aventstack</groupId>
			<artifactId>extentreports</artifactId>
			<version>3.1.2</version>
		</dependency>
		<!-- Testng -->
		<dependency>
			<groupId>org.testng</groupId>
			<artifactId>testng</artifactId>
			<version>6.10</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>org.apache.maven.surefire</groupId>
			<artifactId>surefire</artifactId>
			<version>2.18.1</version>
			<type>pom</type>
		</dependency>
		<dependency>
			<groupId>com.google.code.gson</groupId>
			<artifactId>gson</artifactId>
			<version>2.8.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.httpcomponents</groupId>
			<artifactId>httpclient</artifactId>
			<version>4.3.3</version>
		</dependency>
		<dependency>
			<groupId>com.google.guava</groupId>
			<artifactId>guava</artifactId>
			<version>23.0</version>
		</dependency>
		<dependency>
			<groupId>cglib</groupId>
			<artifactId>cglib</artifactId>
			<version>3.1</version>
		</dependency>
		<dependency>
			<groupId>commons-validator</groupId>
			<artifactId>commons-validator</artifactId>
			<version>1.4.1</version>
		</dependency>
		<!-- Java mail api -->
		<dependency>
			<groupId>javax.mail</groupId>
			<artifactId>mail</artifactId>
			<version>1.4</version>
		</dependency>
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>1.3.2</version>
		</dependency>
		<dependency>
			<groupId>net.sf.saxon</groupId>
			<artifactId>saxon</artifactId>
			<version>8.7</version>
		</dependency>
	</dependencies>

	<build>
		<pluginManagement><!-- lock down plugins versions to avoid using Maven 
				defaults (may be moved to parent pom) -->
			<plugins>
				<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
				<plugin>
					<artifactId>maven-clean-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>
				<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
				<plugin>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.0.2</version>
				</plugin>
				<plugin>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.8.0</version>
				</plugin>
				<plugin>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>2.22.1</version>
					<configuration>
						<suiteXmlFiles>
							<suiteXmlFile>./src/test/resources/testng.xml</suiteXmlFile>
						</suiteXmlFiles>
					</configuration>
				</plugin>
				<plugin>
					<artifactId>maven-jar-plugin</artifactId>
					<version>3.0.2</version>
				</plugin>
				<plugin>
					<artifactId>maven-install-plugin</artifactId>
					<version>2.5.2</version>
				</plugin>
				<plugin>
					<artifactId>maven-deploy-plugin</artifactId>
					<version>2.8.2</version>
				</plugin>
				<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
				<plugin>
					<artifactId>maven-site-plugin</artifactId>
					<version>3.7.1</version>
				</plugin>
				<plugin>
					<artifactId>maven-project-info-reports-plugin</artifactId>
					<version>3.0.0</version>
				</plugin>
			</plugins>
		</pluginManagement>
	</build>
</project>

You're missing out a lot of basic things in your project.

Please start watching the videos again from the beginning. 

Also make sure that you are using JDK8 only unless otherwise specified in the project requirements.


A
Ashish Thakur Replied on 02/03/2020

Also, the project shared in the code is the final working project.


P
Preetinder Virk Replied on 04/03/2020

I had only asked basically to share complete code of Module TRAINING VIDEO - 22 JUNIT AND HYBRID (KEYWORD+DATA) FRAMEWORKwith all dependencies and functions as in video. I was able to get a previous version of the project on Hybrid Framework and it works with JDK 13 too. I don't hence need to re-watch the videos. This post can be closed as my request was not addressed. 


A
Ashish Thakur Replied on 05/03/2020

The final code is uploaded in the download code section. Please find the latest code there.

Also make sure that you are using JDK 8 Only.


Related Posts