Automation Using Selenium Webdriver

Thursday 10 November 2016

Generate Customized ExcelReports Using TestNG in Selenium

There are many ways to Generate Reports in Selenium. Now I’d like to generate an excel reports. This report will give you the number test cases has been Passed and Failed or Skipped. It’s quite simple to generate this report. All you need to do is just giving a Proper Name and Destination Path (if you’re using the latest jar 4.0.1).
Note: TestNG is required. Without testNG this code won’t work.
There are few steps to be followed to generate Excel Reports. Here I am sharing the snippet.
Download the latest Jar from here ExcelReportGenerator version 4.0.1. Add this Jar into your project BuildPath.
If You’re using Jar 4.0.1 version then you can specify the desired location and File name in the code itself.
Follow the Steps Specified :
Step1: Create a Package ‘ExcelResults’ under your Project (Optional, if you’re using 4.0.1 version).
step2: Create  the test cases which you’d like to automate using TestNg (by using @Test, BeforeTest…….) as Shown.
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
public class Test_98 {
@Test(priority = 1)
public void VerfyingTestCaseID_001() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 2)
public void VerfyingTestCaseID_002() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 3)
public void VerfyingTestCaseID_003() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 4)
public void VerfyingTestCaseID_004() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 5)
public void VerfyingTestCaseID_005() {
System.out.println(“test”);
System.out.println(“this”);
Assert.assertEquals(“validText”, “InvalidText”);
}
@Test(priority = 6)
public void VerfyingTestCaseID_006() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 7)
public void VerfyingTestCaseID_007() {
System.out.println(“test”);
System.out.println(“this”);
Assert.assertEquals(“validText”, “InvalidText”);
}
@Test(priority = 8)
public void VerfyingTestCaseID_008() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 9)
public void VerfyingTestCaseID_009() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 10)
public void VerfyingTestCaseID_010() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 11)
public void VerfyingTestCaseID_011() {
System.out.println(“test”);
System.out.println(“this”);
Assert.assertTrue(false);
}
@Test(priority = 12)
public void VerfyingTestCaseID_012() {
System.out.println(“test”);
System.out.println(“this”);
Assert.assertTrue(false);
}
@Test(priority = 13)
public void VerfyingTestCaseID_013() {
System.out.println(“test”);
System.out.println(“this”);
}
@Test(priority = 14)
public void VerfyingTestCaseID_014() {
System.out.println(“test”);
System.out.println(“this”);
}
}
Step3 : Create a testng.xml file under your Project as Shown.
<suite name=”Build 2.0.1″>
<test name=”TestReport”>
<classes>
<class name=”Test_98″ />
</classes>
</test>
</suite>
Now Run the testng.xml file.
Step 4 : Now Create a Class ‘ExcelGenerate’  and paste the following code.
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
public class ExcelGenerate {
public static void main(String[]args) throws ParserConfigurationException, IOException, SAXException
{
ExcelReportGenerator.generateExcelReport(“MyProject.xls”, “D:\\workspace”);
}
}
Step5: Refresh the package ‘ExcelResults’ (If you’re using older version).
Step5 : Results will be generated at your desired path given. (If you’re using 4.0.1 version).
Click here to see the generated report.
Now you see the excelReport Generated. Its so simple huh !!!

*If you see the columns in the excel were disturbed please change the settings or Use the latest Version. I have made this using  ‘Libre’.

Infosys Asked 3 Years Selenium Testing Position

From Java
---------------
1.What is the Difference between final,finally,finalize
2.what is the difference between Call by value and call by referance
3.How to find out the length of the string without using length function
4.How to find out the part of the string from a string
5.difference between throw & throws
6.What is binding(Early and Late binding)
He give Programes
1.Reverse a number
2.1,2,3,4,5,65,76,5,,4,33,4,34,232,3,2323,
find the biggest number among these
simple string programe.
what is exception types of exception
-----------------------------------------
From manual
----------------------------------------
what is the testcase technique
why we write test case.
bug life cycle
what are the different status of bug
what is the different between functional and smoke testing
what is STLC.
he gives a application & tell to write the scenario
some manual testing concepts
-----------------------------
From Selenium
-----------------------------
1.Explain ur roles and responsibilities
2.Explain Automation Life Cycle
3.Which Framework U have Used?
4.Explain Ur Framework
5.What are the things u stored in PageFactory ? Why ?
6.Explain TestNG
7.What are the annotations U have Used ?
8.What is Constructor
9.Where u have used constructor in Selenium?
10.Which model u have followed in ur company?
11.How do you handle dynamics objects in a webpage?
12.How do you handle untrusted SSL certificate in Webdriver?
13.What is the difference between beforemethod and beforetest?
14.How to verify a particular image and its size in a webpage?(Webpage has got many images out of which you have select particular one)
15.What is the use of DesiredCapabilities in Selenium WebDriver?
16.How do you know the Remote m/c details. Like OS, browsers details.
17.How do you find out active elements?