I am using selenium 3.141.59 to automate gmail application as an example in Edge in IE Mode.
If I use Selenium 4.0.0 or greater , PageFactory.initElements doesn't support .
I have to execute script for below environment :
Windows 11 (64 bit)
Edge 105.0.1343.50 ( Open in IE mode. Its requirement of an application)
DriverManager.java
package managers;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.UnexpectedAlertBehaviour;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Parameters;
public class DriverManager {
public WebDriver driver;
DesiredCapabilities capabilities;
#SuppressWarnings("unchecked")
#Parameters({ "browserName" })
#BeforeClass(alwaysRun = true)
public void initialize(String browser) throws IOException, InterruptedException {
if (browser.equalsIgnoreCase("edge")) {
System.setProperty("webdriver.edge.driver",
"D:\\My_Workspace\\EdgeInIEModeTest\\drivers\\msedgedriver.exe");
capabilities = new DesiredCapabilities();
// Creating an object of EdgeDriver
driver = new EdgeDriver();
driver.manage().window().maximize();
// Deleting all the cookies
driver.manage().deleteAllCookies();
// Specifiying pageLoadTimeout and Implicit wait
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} else if (browser.equalsIgnoreCase("edgeForWindows11")) {
// Selenium 4 + version
// System.out.println("edgeForWindows11 IN");
// System.setProperty("webdriver.ie.driver",
//
// "D:\My_Workspace\EdgeInIEModeTest\drivers\IEDriverServer32bit.exe\IEDriverServer32bit.exe");
//
// InternetExplorerOptions ieOptions = new InternetExplorerOptions();
// ieOptions.attachToEdgeChrome();
// ieOptions.withEdgeExecutablePath("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe");
//
// driver = new InternetExplorerDriver(ieOptions);
// Selenium 3.141.59
System.setProperty("webdriver.ie.driver",
"D:\\My_Workspace\\EdgeInIEModeTest\\drivers\\IEDriverServer32bit.exe");
InternetExplorerOptions edgeIe11Options = new InternetExplorerOptions();
Map<String, Object> ops = (Map<String, Object>) edgeIe11Options.getCapability("se:ieOptions");
ops.put("ie.edgechromium", true);
ops.put("ie.edgepath", "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"); // Edge Browser
// directory
// path
edgeIe11Options.introduceFlakinessByIgnoringSecurityDomains();
edgeIe11Options.ignoreZoomSettings();
edgeIe11Options.enablePersistentHovering();
edgeIe11Options.takeFullPageScreenshot();
edgeIe11Options.disableNativeEvents();
edgeIe11Options.requireWindowFocus();
edgeIe11Options.destructivelyEnsureCleanSession();
edgeIe11Options.setCapability("ignoreProtectedModeSettings", true);
edgeIe11Options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE);
driver = new InternetExplorerDriver(edgeIe11Options);
}
}
public static String getIPAddress() {
InetAddress IP = null;
try {
IP = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return IP.getHostAddress();
}
public void launchGmailApplication() throws InterruptedException, IOException {
System.out.println("In launchApplication method for EdgeInIEMode Windows 11");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://www.google.com");
Thread.sleep(3000);
try {
driver.switchTo().alert().accept();
} catch (Exception a) {
}
}
#AfterClass(alwaysRun = true)
public void TeardownTest() {
System.out.println(driver.getCurrentUrl());
if (null != driver) {
driver.close();
driver.quit();
}
}
}
BasePage.Java
package pages;
import org.openqa.selenium.WebDriver;
public abstract class BasePage {
public WebDriver driver;
public BasePage(WebDriver driver) {
// TODO Auto-generated constructor stub
this.driver = driver;
}
}
LogInPage.Java
import java.io.IOException;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import managers.DriverManager;
import pages.LogInPage;
public class LogInTest extends DriverManager {
public LogInPage loginPage;
#BeforeClass(alwaysRun = true)
public void launchApplication() throws InterruptedException, IOException {
loginPage = PageFactory.initElements(driver, LogInPage.class);
launchGmailApplication();
}
#Test
public void invokeDriver() {
System.out.println("Hello");
loginPage.clickOnGmailMenuOption();
loginPage.clickOnSignInButton();
loginPage.logInToGmailApplication();
}
}
LogInTest.Java
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import managers.DriverManager;
import pages.LogInPage;
public class LogInTest extends DriverManager {
public LogInPage loginPage;
#BeforeMethod(alwaysRun = true)
public void launchApplication() {
loginPage = PageFactory.initElements(driver, LogInPage.class);
loginPage.logInToGmailApplication();
}
#Test
public void invokeDriver() {
System.out.println("Hello");
loginPage.clickOnGmailMenuOption();
loginPage.clickOnSignInButton();
loginPage.logInToGmailApplication();
}
}
POM.xml
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cemtrex.com</groupId>
<artifactId>EdgeInIEModeTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.3.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>if-suite-exists</id>
<activation>
<property>
<name>!env.SUITES</name>
</property>
</activation>
<properties>
<suites>GlobalSuite</suites>
</properties>
</profile>
<!-- browsers -->
<profile>
<id>firefox</id>
<properties>
<capabilities>/firefox.capabilities</capabilities>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>chrome</id>
<properties>
<capabilities>/chrome.capabilities</capabilities>
</properties>
</profile>
<profile>
<id>ie</id>
<properties>
<capabilities>/ie.capabilities</capabilities>
</properties>
</profile>
</profiles>
<properties>
<suites>${env.SUITES}</suites>
<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>
<build>
<resources>
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<!--<inherited>true</inherited> -->
<configuration>
<!--<testFailureIgnore>false</testFailureIgnore> -->
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/suites/${suites}.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>
After Execute :
Related
I am facing a problem when serializing an object. The object is a representation of a stack. The Stack can either consist of individual Layers or a sequence of Layers stored in a LayerSequence. So, Layer and LayerSequence implement Stackable and the Stack holds a List of Stackable. Since Layer and LayerSequence are stored independently of Stack, I use XmlIDREF to reference them by a name.
To help JAXB resolving the interface implementations, I define
#XmlElementWrapper(name="layers")
#XmlElements({
#XmlElement(name="layer", type=Layer.class)
,#XmlElement(name="layerSequence", type=LayerSequence.class)
})
#XmlIDREF
private List<S> layers;
When serializing with a generic Stack<? extends Stackable> the type is not transferred as I would have expected. The type is changed to a String containing the XmlID. The result is:
<stack name="stack">
<layers>
<layer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">layer</layer>
</layers>
</stack>
For a specific example, where I know, that only Layers and no LayerSequences are used and I define
#XmlElementWrapper(name="layers")
#XmlElements({
#XmlElement(name="layer", type=Layer.class)
})
#XmlIDREF
private List<S> layers;
the type is properly defined as expected:
<stack name="stack">
<layers>
<layer>layer</layer>
</layers>
</stack>
The same works the other way around for LayerSequence.
What am I missing here? Is this a problem because LayerSequence itself uses Layers? How can I circumvent this?
MWE
Code
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.PropertyException;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlTransient;
public class Main
{
public static void main(String[] args) throws PropertyException, JAXBException{
LayerValueImpl layerValue1 = new LayerValueImpl("layerValue");
Layer<LayerValueImpl> layer = new Layer<>("layer",layerValue1);
List<Layer<? extends AbstractLayerValue>> layers = new ArrayList<>();
layers.add(layer);
Stack<? extends Stackable> stack = new Stack<>("stack",layers);
//
JAXBContext jc = JAXBContext.newInstance(Stack.class);
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(stack, System.out);
}
public static interface Identifiable<
T extends Identifiable
>
{
public void setName(String name);
public String getName();
}
public static interface Stackable<
T extends Stackable
>
extends
Identifiable<T>
{
#XmlAttribute
#XmlID
#Override
public String getName();
}
#XmlTransient
#XmlAccessorType(XmlAccessType.FIELD)
public static abstract class AbstractLayerValue<
T extends AbstractLayerValue
>
implements
Identifiable<T>
{
#XmlAttribute
#XmlID
private String name;
public AbstractLayerValue() {}
public AbstractLayerValue(
String name
) {
this.name = name;
}
#Override
public void setName(String v){this.name = v;}
#Override
public String getName(){return name;}
}
#XmlRootElement
public static class LayerValueImpl
extends
AbstractLayerValue<
LayerValueImpl
>
{
public LayerValueImpl() {}
public LayerValueImpl(String name) {
super(name);
}
}
#XmlTransient
#XmlAccessorType(XmlAccessType.FIELD)
public static abstract class AbstractLayerSuperClass<
T extends AbstractLayerSuperClass
>
implements
Identifiable<T>
{
#XmlAttribute
#XmlID
private String name;
public AbstractLayerSuperClass() {}
public AbstractLayerSuperClass(
String name
) {
this.name = name;
}
#Override
public void setName(String v){this.name = v;}
#Override
public String getName(){return name;}
}
#XmlRootElement
#XmlSeeAlso({
LayerValueImpl.class
})
public static class Layer<
V extends AbstractLayerValue
>
extends
AbstractLayerSuperClass<
Layer<V>
>
implements
Stackable<Layer<V>>
{
private V value;
public Layer() {}
public Layer(
String name
,V value
) {
super(
name
);
this.value = value;
}
public void setValue(V v){this.value = v;}
public V getValue(){return value;}
}
#XmlRootElement
#XmlAccessorType(XmlAccessType.FIELD)
public static class LayerSequence
implements
Stackable<LayerSequence>
{
#XmlAttribute
#XmlID
private String name;
private List<Layer<? extends AbstractLayerValue>> layers;
public LayerSequence() {}
public LayerSequence(
String name
,List<Layer<? extends AbstractLayerValue>> layers
) {
this.name = name;
this.layers = layers;
}
#Override
public void setName(String v){this.name = v;}
#Override
public String getName(){return name;}
public void setLayers(List<Layer<? extends AbstractLayerValue>> v){this.layers = v;}
public List<Layer<? extends AbstractLayerValue>> getLayers(){return layers;}
}
#XmlRootElement
#XmlAccessorType(XmlAccessType.FIELD)
public static class Stack<
S extends Stackable
>
implements
Identifiable<Stack<S>>
{
#XmlAttribute
#XmlID
private String name;
#XmlElementWrapper(name="layers")
#XmlElements({
#XmlElement(name="layer", type=Layer.class)
,#XmlElement(name="layerSequence", type=LayerSequence.class)
})
//#XmlElementRefs({
// #XmlElementRef(type=Layer.class, name="layer"),
// #XmlElementRef(type=LayerSequence.class, name="layerSequence")
//})
#XmlIDREF
private List<S> layers;
public Stack() {}
public Stack(
String name
,List<S> layers
) {
this.name = name;
this.layers = layers;
}
#Override
public void setName(String v){this.name = v;}
#Override
public String getName(){return name;}
public void setLayers(List<S> v){this.layers = v;}
public List<S> getLayers(){return layers;}
}
}
POM
<?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>de.mr</groupId>
<artifactId>test</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<!-- PROPERTIES -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- System -->
<java.version>16</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.plugin.compiler.version>3.8.1</maven.plugin.compiler.version>
<maven.plugin.enforcer.version>3.0.0-M2</maven.plugin.enforcer.version>
<maven.plugin.jar.version>3.2.0</maven.plugin.jar.version>
<maven.plugin.release.version>2.5.3</maven.plugin.release.version>
<!-- Log4j2 -->
<log4j.api.version>2.13.1</log4j.api.version>
<log4j.core.version>2.13.1</log4j.core.version>
<!-- Lombok -->
<lombok.version>1.18.22</lombok.version>
<maven.plugin.lombok.version>1.18.20.0</maven.plugin.lombok.version>
<!-- Stuff for JAXB -->
<javax.xml.bind.jaxb-api.version>2.4.0-b180830.0359</javax.xml.bind.jaxb-api.version>
<javax.activation.activation.version>1.1</javax.activation.activation.version>
<org.glassfish.jaxb.jaxb-runtime.version>2.3.0-b170127.1453</org.glassfish.jaxb.jaxb-runtime.version>
<maven.plugin.jaxb2.version>2.5.0</maven.plugin.jaxb2.version>
<maven.plugin.jaxb2.locale>en</maven.plugin.jaxb2.locale>
<maven.plugin.jaxb2.clearOutputDir>true</maven.plugin.jaxb2.clearOutputDir>
<maven.plugin.jaxb2.createJavaDocAnnotations>false</maven.plugin.jaxb2.createJavaDocAnnotations>
</properties>
<!-- DEPENDENCIES -->
<dependencies>
<!-- -->
<!-- 3rd party -->
<!-- -->
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- Log4j2 -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.core.version}</version>
</dependency>
<!-- Stuff for JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${javax.xml.bind.jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>${javax.activation.activation.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>${org.glassfish.jaxb.jaxb-runtime.version}</version>
</dependency>
</dependencies>
<!-- BUILD -->
<build>
<!-- PLUGINS -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.plugin.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.plugin.enforcer.version}</version>
<executions>
<execution>
<goals>
<goal>enforce</goal>
</goals>
</execution>
</executions>
<configuration>
<rules>
<requireJavaVersion>
<version>${java.version}</version>
</requireJavaVersion>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven.plugin.release.version}</version>
<configuration>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
</configuration>
</plugin>
<!-- Delombok -->
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
<version>${maven.plugin.lombok.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>delombok</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<addOutputDirectory>false</addOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<withoutUnicodeEscape>true</withoutUnicodeEscape>
</configuration>
</plugin>
<!-- Generate a XSD schema -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>${maven.plugin.jaxb2.version}</version>
<executions>
<execution>
<id>schemagen</id>
<goals>
<goal>schemagen</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/java/de/mr/test/jaxbschemagenlombok</source>
</sources>
<outputDirectory>${project.build.directory}/generated-sources/schemas</outputDirectory>
<clearOutputDir>${maven.plugin.jaxb2.clearOutputDir}</clearOutputDir>
<createJavaDocAnnotations>${maven.plugin.jaxb2.createJavaDocAnnotations}</createJavaDocAnnotations>
<locale>${maven.plugin.jaxb2.locale}</locale>
</configuration>
</plugin>
</plugins>
<!-- THIS IS THE FINAL NAME OF THE JAR -->
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
</project>
I have added the extent report dependency from the maven repository in pom.xml but when I am trying to use "ExtentSparkReporter" in my code, the import is not happening.
Below is my pom.xml
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.9</version>
</dependency>
Below is my file:
public void config()
{
String path =System.getProperty("user.dir")+"\\reports\\index.html";
ExtentSparkReporter reporter = new ExtentSparkReporter(path);
//no methods have been initiated in config
}
public void initialDemo()
{
System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe");
WebDriver driver =new ChromeDriver();
driver.get("https://www.google.com");
System.out.println(driver.getTitle());
driver.close();
//test.fail("Result do not match");
}
}
It will be a great help if anyone helps me regarding this.
P:s - As I have checked some of the solution to downgrade the extendreports library , so I am using 4.0.9.
Thanks
you are missing some key components:
The ExtentSparkReporter needs to be attached to the ExtentReports object
You need to flush the ExtentReports object at the end of all tests
Here's a sample using 5.0.9 ( it works with 4.0.9 also)
Using these maven dependencies:
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.9</version>
</dependency>
</dependencies>
I'm using testng to manipulate the order the code is executed.
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.reporter.ExtentSparkReporter;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.*;
public class TestDemo {
public ExtentReports extent = new ExtentReports();
public ExtentSparkReporter reporter;
public ExtentTest test;
public WebDriver driver;
#BeforeSuite
public void beforeSuite() { // it will be executed only once, before all the tests, so we won't have duplicate reports or override the file for each test
System.setProperty("webdriver.chrome.driver", "C://chromedriver.exe"); //set the chrome path for all tests only once
String path = System.getProperty("user.dir")+"\\reports\\index.html";
reporter = new ExtentSparkReporter(path);
}
#BeforeMethod
public void beforeMethod(){
driver = new ChromeDriver(); // create the chrome instance before each tests
}
#Test
public void aFastTest() {
test = extent.createTest("aFastTest");
driver.get("https://www.google.com");
System.out.println(driver.getTitle());
driver.close();
test.fail("Failed");
}
#Test
public void anotherTestPassed() {
test = extent.createTest("anotherTestPassed");
driver.get("https://www.google.com");
System.out.println(driver.getTitle());
driver.close();
test.pass("hey my test passed");
}
#AfterSuite
public void afterSuite(){ //executed after all the tests have ran
extent.attachReporter(reporter);
extent.flush();
}
}
I am trying to execute tests in parallel using testng and selenium. when I triggered the tests, its executing successfully on one session, and the other session it just hangs.. am seeing following error in logs.
I tried using methods/classes/tests as parallel options in testng.xml. its same issue in all cases.
Exception in thread "pool-1-thread-1" org.openqa.selenium.WebDriverException: java.net.SocketException: Software caused connection abort: recv failed
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: 'PF12FNSG20HE', ip: '146.27.24.164', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_171'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
at org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:294)
at AEMSites.Base.getScreenShot(Base.java:186)
at resources.TestListeners.onTestFailure(TestListeners.java:36)
at org.testng.internal.Invoker.runTestListeners(Invoker.java:1895)
at org.testng.internal.Invoker.runTestListeners(Invoker.java:1879)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1292)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
My code is as follows:
POM File:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>AEMSites</groupId>
<artifactId>ChevronECOM</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ChevronECOM</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.13.0</version>
</dependency>
<!-- TestNG -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>compile</scope>
</dependency>
<!-- Extent Reports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.21.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<useSystemClassLoader>true</useSystemClassLoader>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>parallel</name>
<value>methods</value>
</property>
<property>
<name>threadCount</name>
<value>2</value>
</property>
<property>
<name>dataproviderthreadcount</name>
<value>2</value>
</property>
</properties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.15</version>
</plugin>
</plugins>
</build>
</project>
Test Ng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name=" test suite" parallel="methods" thread-count="2">
<listeners>
<listener class-name="resources.TestListeners"/>
<listener class-name="ExtentReportsChevron"/>
<listener class-name="resources.RetryListenerClass"/>
</listeners>
<test name="Chrome Tests" parallel="methods" thread-count="2">
<classes>
<class name="AEMSites.TechronCleanHomePageTests"/>
<class name="AEMSites.TechronCleanContactUsPageTests"/>
<class name="AEMSites.TechronCleanFAQTests"/>
<class name="AEMSites.TechronCleanWhereToBuyPageTests"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
My Tests:
package AEMSites;
import java.lang.reflect.Method;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.openqa.selenium.WebDriver;
import AEMSites.pageObjects.TechronCleanHomePage;
import AEMSites.pageObjects.TechronCleanSearchResultsPage;
public class TechronCleanHomePageTests extends Base
{
TechronCleanHomePage tch;
TechronCleanSearchResultsPage tcsrp;
//public static String experience;
#BeforeMethod
public void HomePageNavigation(Method method) throws Throwable
{
//FileInputStream fis = new FileInputStream("C:\\Users\\hpak\\ChevronECOM\\Variables.properties");
//prop.load(fis);
//experience=prop.getProperty("experience");
System.out.println("Test Executing is: " + method.getName());
driver=initializeDriver();
System.out.println("step1" + driver);
System.out.println("step1" + url);
driver.get(url);
System.out.println("step2");
System.out.print("Expericene in test method is"+experience);
if(experience.equalsIgnoreCase("mobile"))
{
System.out.println("In Home page tests before method in mobile");
tch = new TechronCleanHomePage(driver);
tch.getMobileHamburgerMenu().click();
}
else
{
driver.manage().window().maximize();
}
}
#Test(groups = {"HomePage"})
public void TC_014_VerifyProductsLinkOnHomePage() throws InterruptedException
{
tch = new TechronCleanHomePage(driver);
System.out.println("In test case method, experience is "+experience);
if(experience.equalsIgnoreCase("mobile"))
{
tch.getProducts_mobile().click();
TimeUnit.SECONDS.sleep(10);
}
else
{
System.out.println("In desktop method");
tch.getProducts().click();
}
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("products.html"));
}
#Test(groups = {"HomePage"})
public void TC_043_VerifyWhyTechronLinkOnHomePage()
{
tch = new TechronCleanHomePage(driver);
tch.getWhyTechron().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("why-techron.html"));
}
#Test(groups = {"HomePage"})
public void TC_002_VerifySearchAndVisitProductPage()
{
System.out.println("In search test");
tch = new TechronCleanHomePage(driver);
tcsrp = new TechronCleanSearchResultsPage(driver);
tch.getSearchIcon().click();
tch.getSearchBar().sendKeys("Motor Oil");
tch.getSearchBar().sendKeys(Keys.RETURN);
try
{
Assert.assertTrue(driver.getPageSource().contains("Motor Oil"));
Assert.assertTrue(driver.getPageSource().contains("Search Results"));
Assert.assertTrue(driver.getPageSource().contains("Techron Complete Fuel System Cleaner"));
}
catch (Error e)
{
System.out.println(e);
}
tcsrp.getProductLink().click();
try
{
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("techron-complete-fuel-system"));
Assert.assertTrue(driver.getPageSource().contains("Concentrate Plus Complete Fuel System Cleaner"));
}
catch (Error e)
{
System.out.println(e);
}
}
#Test(groups = {"HomePage"})
public void TC_012_VerifyProductLineupOnHomePage()
{
tch = new TechronCleanHomePage(driver);
String findproductext=tch.getFindProductText().getText();
System.out.print("one"+findproductext);
Assert.assertTrue(findproductext.contains("FIND A PRODUCT"));
String imagesrc=tch.getImageSource().getAttribute("src");
System.out.print("two"+imagesrc);
Assert.assertTrue(imagesrc.contains("/content/dam"));
tch.getImageSource().click();
String imagesrcafterclick=tch.getImageSource().getAttribute("src");
System.out.print("three"+imagesrcafterclick);
Assert.assertTrue(imagesrcafterclick.contains("/content/dam"));
Assert.assertTrue(tch.getLearnMoreBtnOnPrdLineUp().isDisplayed());
}
#Test(groups = {"HomePage"})
public void TC_041_VerifyWhereToBuyOnHomePage()
{
tch = new TechronCleanHomePage(driver);
tch.getWhereToBuy().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("where-to-buy.html"));
}
#Test(groups = {"HomePage"})
public void TC_046_VerifyFAQLinkOnHomePage()
{
tch = new TechronCleanHomePage(driver);
tch.getFAQ().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("faq.html"));
}
#Test(groups = {"Footer"})
public void TC_003_VerifyContactUsLinkOnFooter()
{
tch = new TechronCleanHomePage(driver);
tch.getContactUs().click();
System.out.println("Current Window url is"+tch.getCurrentWindowUrl());
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("contact-us.html"));
}
#Test(groups = {"HomePage"})
public void TC_010_VerifyMarketFormOnHomePage() throws InterruptedException
{
tch = new TechronCleanHomePage(driver);
tch.getMarketoFirstName().sendKeys("TestFirst");
tch.getMarketoLastName().sendKeys("TestLast");
tch.getMarketoEmail().sendKeys("ignore#gmail.com");
tch.getMarketoSubmitBtn().click();
TimeUnit.SECONDS.sleep(5);
System.out.println("Current Window url is"+tch.getCurrentWindowUrl());
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("aliId"));
}
#Test(groups = {"Footer"})
public void TC_004_VerifyTermsOfUseLinkOnFooter()
{
tch = new TechronCleanHomePage(driver);
tch.getTermsOfUse().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("terms-of-use"));
Assert.assertTrue(driver.getPageSource().contains("terms of use"));
}
#Test(groups = {"Footer"})
public void TC_005_VerifyPrivacyPolicyOnFooter()
{
tch = new TechronCleanHomePage(driver);
tch.getPrivacyPolicy().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("privacy"));
Assert.assertTrue(driver.getPageSource().contains("privacy statement"));
}
#Test (groups = {"Footer"})
public void TC_006_VerifyChevronLubricantsLinkOnFooter()
{
tch = new TechronCleanHomePage(driver);
tch.getChevronLubricants().click();
Assert.assertTrue((tch.getCurrentWindowUrl()).contains("https://www.chevronlubricants.com/"));
}
#Test (enabled=false)
public void VerifyTabItemsOnHomePage()
{
List<WebElement> allLinks = ((WebDriver) driver).findElements(By.tagName("a"));
System.out.println("In Verify Tab items test");
System.out.println(allLinks);
for (WebElement w : allLinks)
{
w.click();
if (((WebDriver) driver).findElement(By.xpath("Element on the page")).isDisplayed())
{
System.out.println("Link:"+w.getText()+"is working");
}
else
{
System.out.println("Link:"+w.getText()+"is not working");
}
((WebDriver) driver).navigate().back();//To come back to the Home screen
}
}
#AfterMethod
public void closeAll()
{
//System.out.println("Test:" + result.getMethod().getMethodName()+ " is "+status.toString().toUpperCase());
driver.quit();
//driver.close();
driver=null;
}
}
can someone please suggest.
Try to run with
#BeforeMethod(alwaysRun = true)
public void HomePageNavigation(Method method)
And
#AfterMethod(alwaysRun = true)
public void closeAll()
I've been trying to perform a POST from a jersey client but continue to run into the following exception:
Caused by: java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3071)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:325)
at org.glassfish.jersey.client.internal.HttpUrlConnector.setOutboundHeaders(HttpUrlConnector.java:424)
at org.glassfish.jersey.client.internal.HttpUrlConnector.lambda$_apply$0(HttpUrlConnector.java:381)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:195)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:189)
at org.glassfish.jersey.message.internal.CommittingOutputStream.commit(CommittingOutputStream.java:257)
at org.glassfish.jersey.message.internal.OutboundMessageContext.commitStream(OutboundMessageContext.java:825)
at org.glassfish.jersey.client.ClientRequest.doWriteEntity(ClientRequest.java:553)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:498)
at org.glassfish.jersey.client.internal.HttpUrlConnector._apply(HttpUrlConnector.java:384)
at org.glassfish.jersey.client.internal.HttpUrlConnector.apply(HttpUrlConnector.java:282)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:278)
... 63 more
I've tried a ton of answers and solutions in SO with no luck.
Going crazy here, please help!
public class JerseyWithSSL {
public static javax.ws.rs.client.Client getRESTClient() {
try {
TrustManager[] trustMgr = new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted1(X509Certificate[] certs,
String authType) {
}
public void checkServerTrusted1(X509Certificate[] certs,
String authType) {
}
#Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
#Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
}};
SSLContext context = SSLContext.getInstance("SSL");
context.init(null, trustMgr, null);
javax.ws.rs.client.Client client = ClientBuilder.newBuilder().sslContext(context)
.hostnameVerifier(new HostnameVerifier() {
#Override
public boolean verify(String arg0, SSLSession arg1) {
// TODO Auto-generated method stub
return true;
}
}).build();
return client;
} catch (NoSuchAlgorithmException | KeyManagementException ex) {
Logger.getLogger(JerseyWithSSL.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
Code which uses the above class (exception thrown here):
// send notification to all subscriptors for event: attendee.create
if (!subscriptions.isEmpty()) {
try {
Client client = JerseyWithSSL.getRESTClient();
for (Subscription sub : subscriptions) {
System.out.println("Subscription: \n" + sub.getEventName() + "\n" + sub.getTargetUrl());
Response resp = client.target(sub.getTargetUrl())
.request(MediaType.APPLICATION_JSON)
.post(Entity.entity(newAttdee, MediaType.APPLICATION_JSON));
System.out.println("Status: " + resp.getStatus());
System.out.println(resp.getEntity().toString());
resp.close();
}
} catch (Exception ex) {
Logger.getLogger(AttendeeResource.class.getName()).log(Level.SEVERE, null, ex);
}
}
Adding pom.xml
<?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>ON24Hooks</groupId>
<artifactId>ON24_Zapier_Hooks</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>ON24_Zapier_Hooks</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>2.16</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The IllegalStateException: Already connected is probably masking a SSLHandshakeException, as described in the issue #3000 (previously referenced as JERSEY-2728).
According to the release notes, it was fixed in Jersey 2.23. I would upgrade Jersey to the most recent version though.
I spent some time to figure it out how it is been done in Jersey 2.x. Thanks to Jersey Migration Guide to help me out.
Below is code snippet for how client is build in Jersey 2.x for HTTPS call
public Client getRESTClient() {
TrustManager[] trustMgr= new TrustManager[] { new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted1(X509Certificate[] certs,
String authType) {
}
public void checkServerTrusted1(X509Certificate[] certs,
String authType) {
}
#Override
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
#Override
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {
// TODO Auto-generated method stub
}
} };
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, trustMgr, null);
Client client = ClientBuilder.newBuilder().sslContext(context)
.hostnameVerifier(new HostnameVerifier() {
#Override
public boolean verify(String arg0, SSLSession arg1) {
// TODO Auto-generated method stub
return true;
}
}).build();
return client;
}
Just exception can be occur at any point while it may be SSL certificate validation also which can also current socket layer connection to validate SSLContext.Please debug out try catch block thoroughly also make the execution of your http request with other client also as well from Java Url URLCONNECTION
The IllegalStateException: Already connected is probably masking a SSLHandshakeException. The way to verify/debug this is to use the following JVM flags:
-Djavax.net.debug=ssl:handshake:verbose:keymanager:trustmanager -Djava.security.debug=access:stack
This will cause the JVM to print out a whole bunch of debug information regarding SSL and will show the SSL exception if there is one.
Though my tests ran successfully, I am not able to generate extent-report, below codes and pom.xml I used
Any help is appreciated. Hope I am clear on my question. Please help to solve this issue:
import java.io.File; import java.util.Date;
import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.ExtentReports;
public class ExtentManager {
private static ExtentReports extent;
public static ExtentReports getInstance() {
if (extent == null) {
Date d=new Date();
String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
extent = new ExtentReports("C:\\Users\\dilu316\\Documents"+fileName, true, DisplayOrder.NEWEST_FIRST);
extent.loadConfig(new File(System.getProperty("user.dir")+"//ReportsConfig.xml"));
// optional
extent.addSystemInfo("Selenium Version", "2.53.0").addSystemInfo(
"Environment", "QA");
}
return extent;
}
}
Tests:
public class DummyTestB extends BaseTest{
ExtentReports rep = ExtentManager.getInstance();
ExtentTest test;
#Test
public void testB()
{
test = rep.startTest("DummyTestB");
test.log(LogStatus.INFO, "Starting the test test B");
openBrowser("Mozilla");
test.log(LogStatus.INFO, "Open the Browser");
navigate("appurl");
type("email_id","hara.mohapatra#gmail.com");
click("button_xpath");
verifyTitle();
reportFailure("title does not match");
test.log(LogStatus.PASS, "Test B Passed");
}
#AfterMethod
public void quit()
{
rep.endTest(test);
rep.flush();
}
}
pom.xml:
<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>com.selenium.core.ddf</groupId>
<artifactId>DataDriven_Core_Framework</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DataDriven Core Framework</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
</dependencies>
</project>
Thanks in Advance.
public class BaseClass
{
public static WebDriver driver;
public static ExtentReports report;
public static ExtentTest test;
#BeforeSuite
public void InitIate() throws Exception
{
report = new ExtentReports("YOURPATH", true);
report.loadConfig("YOURPATH);
}
}
public class TestSet1 extends BaseClass
{
#Test (priority=1)
public static void TestCase1()
{
test = report.startTest("TC desc");
// Blah Blah --your steps
report.endTest(test);
report.flush();
}
}