Extent report test is marked as failed when it's node test has been retried
I have a test automation project that uses: Java, Maven, TestNG, Selenium WebDriver and Extent Reports (5.0.9 latest).
Most of my tests are using DataProviders and I also have RetryAnalyzer implemented - test/test case is retried once if it has failed.
My Extent Reports "design" looks like this: a method annotated with @Test is represented by ExtentTest extentTest = extentReports.createTest([...]
. Each case from that method's data provider is represented by a node: extentNode = extentTest.createNode([...]
.
The result of that structure is this:
Sample Test has a data provider with 3 cases. Each case is represented by a node that is listed on the right. A node can be expanded to see steps, logs etc..
The problem that I am having is with scenario like this: one of the data provider cases fail and is retried. The retry run of that case passes.
After the initial run of a case is failed, extentTest
status is set to Fail automatically because I do extentNode.fail([...]
on exception in test method. In @AfterMethod method I remove initially failed node from the report: extentReports.removeTest(extentNode)
but that doesn't change the status of extentTest
- it's status is still returning Fail.
The result of that issue is this:
Sample Test is listed as failed but each node is passed.
I tried extentTest.pass("description")
- it just adds a passed step to a test but does not change the overall test status.
do you know?
how many words do you know
See also questions close to this topic
-
It won't let me run selenium code in IntellJ all of a sudden
I was going to execute my code, which is the one I always execute every day for my tests, but suddenly this error appears and I have hardly found a solution, I don't know if it is possible that you can help me with that, I attach the response from the console
Starting ChromeDriver 102.0.5005.27 (df4a85108ffad4dca2c409c52f24df7ec0204b91-refs/branch-heads/5005_22@{#4}) on port 33567 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 102 Current browser version is 101.0.4951.54 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-V4H61F7', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2' Driver info: driver.version: ChromeDriver remote stacktrace: Backtrace: Ordinal0 [0x003B2733+2434867] Ordinal0 [0x003407A1+1968033] Ordinal0 [0x0022C678+837240] Ordinal0 [0x0024CAC3+969411] Ordinal0 [0x002486DA+952026] Ordinal0 [0x00245F91+941969] Ordinal0 [0x002790B0+1151152] Ordinal0 [0x00278D0A+1150218] Ordinal0 [0x00274256+1131094] Ordinal0 [0x0024E840+976960] Ordinal0 [0x0024F736+980790] GetHandleVerifier [0x00623C72+2515426] GetHandleVerifier [0x0061702F+2463135] GetHandleVerifier [0x0045522A+620442] GetHandleVerifier [0x00454016+615814] Ordinal0 [0x0034707B+1994875] Ordinal0 [0x0034B938+2013496] Ordinal0 [0x0034BA25+2013733] Ordinal0 [0x00354DE1+2051553] BaseThreadInitThunk [0x7632FA29+25] RtlGetAppContainerNamedObjectPath [0x77E87A7E+286] RtlGetAppContainerNamedObjectPath [0x77E87A4E+238] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123) at Selenium.pruebas_activity21.main(CrearOT.java:28) Process finished with exit code 1
I hope you can help me with it. It doesn't say any relevant changes, but it seems that any code I'm trying to do can no longer be executed.
-
How to fix tiktok selenium robot detection
How to fix TikTok selenium robot detection
Background-Info
I'm creating a python selenium bot to do things on the TikTok website. The user will log in manually so the website detecting mouse movement and typing speed is irrelevant.The issue is, is that I can't log in while using selenium
What I've tried
I've tried logging in normally without selenium in incognito mode on chrome with the same Mac address, IP address, and same login details (Which worked!!)
I've tried using random user agents in selenium (Which didn't Work)
I've tried adding the following chrome options
options.add_argument("start-maximized") # Chrome is controlled by automated test software options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option('useAutomationExtension', False) # avoiding detection options.add_argument('--disable-blink-features=AutomationControlled')
What I want
I want to be able to log in without TikTok saying
Too many log-in attempts. Try again later
and for more clarification, I can log in normally without selenium same everything and it works it just doesn't work while in selenium.
Heres is the code for starting selenium
post = "https://www.tiktok.com/@smoothmovesranch/video/7091224442243681579" myProxy = "" #configuration options = Options() prox = Proxy() prox.proxy_type = ProxyType.MANUAL prox.http_proxy = myProxy prox.ssl_proxy = myProxy capabilities = webdriver.DesiredCapabilities.CHROME prox.add_to_capabilities(capabilities) options.add_argument("window-size=1400,600") options.add_argument("--incognito") driver = webdriver.Chrome(executable_path = os.path.join(os.getcwd(), 'chromedriver'), options=options) #opens tiktok login page driver.get('https://www.tiktok.com/login/phone-or-email/email')
-
Python Web Scraping extract results from Post
I'm using Python \ Selenium \ Chrome Driver
I'm just after some advice, is it actually possible to perform a POST in Python via requests and then actually extract data from the result? Also through into the mix the webpage is rendered via Javascript so I need to render it first.
For a GET I can perform this via Beautiful Soup using the Chrome driver, but for some reason I just cannot get it to work via requests. (As I understand driver does not support POST??)
For eg:
payload = {'Id': 12345} url = requests.post('https://mywebsite//RecordRest/getTransaction', data=payload) print("Status code: ", url.status_code)
For example, when I execute the above I do get a 200 response, but its actually then extracting the data from the webpage - which is in JSON.
I'm just wondering if this is possible via a POST as I've been spending a lot of time on this and cannot seem to get it to work.
Any pointers or suggestions would be helpful.
-
Gradle Issue with TestNG : No tests found for given includes
I am having difficulties with testNG + Gradle. My tests have worked fine, but I made some changes to the file where I have tests, and now this issue pops up.
"Execution failed for task ':....'.
No tests found for given includes : [.....]
I have this in place, but it doesn't help.
test { useTestNG() }
What does error mean exactly, and how do I resolve it?
-
Running TestNG with Maven
I am trying to run TestNG/Selenium a specific test suite, but I can't get it to run the test. The command I am running is:
mvn test -Dsuitefile=admin_tests.xml
The admin_tests.xml contains:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "https:://testng.org/testng-1.0.dtd"> <suite name="Administration - All"> <test name="Users tab tests" thread-count="1"> <packages> <package name="appOne.testcases.ui.admin.users.*"/> </packages> </test> <test name="User roles tab tests" thread-count="1"> <packages> <package name="appOne.testcases.ui.admin.userRoles.*"/> </packages> </test> </suite>
The directory structure is:
/test-suites/admin_tests.xml /src/test/java/appOne/testcases/ui/admin/users/users_testcase1.xml /src/test/java/appOne/testcases/ui/admin/users/users_testcase2.xml /src/test/java/appOne/testcases/ui/admin/users/users_testcase3.xml /src/test/java/appOne/testcases/ui/admin/userRoles/userRoles_testcase1.xml /src/test/java/appOne/testcases/ui/admin/userRoles/userRoles_testcase2.xml /src/test/java/appOne/testcases/ui/admin/users/userRoles_testcase3.xml
Any help would really be appreciated as I don't understand what I am doing wrong. When I run the command I get 0 tests run.
pom.xml is:
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>org.example</groupId> <artifactId>automation</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.36</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.36</version> </dependency> <!-- https://mvnrepository.com/artifact/org.assertj/assertj-core --> <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> <version>3.22.0</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>4.1.3</version> </dependency> <!-- https://mvnrepository.com/artifact/org.testng/testng --> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.5</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson --> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.9.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.google.http-client/google-http-client-gson --> <dependency> <groupId>com.google.http-client</groupId> <artifactId>google-http-client-gson</artifactId> <version>1.41.6</version> </dependency> <!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager --> <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>5.1.1</version> </dependency> <!-- Dependency for TestRail APIClient --> <!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple --> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> </dependencies> <properties> <maven.compiler.source>18</maven.compiler.source> <maven.compiler.target>18</maven.compiler.target> </properties> </project>
-
How to log unique statements for each tests in the ExtentReport with the implementation of ITestListener?
I am currently using the ExtentReport framework to generate a comprehensive test report after TestNG completes its suite of test class using Selenium. To make the process easier and to reduce code, I am using a listener class to automate the Test Success and Test Failure scenerios such that in case of every success/failure, there will some actions done to the report automatically. The listener implementation goes like this:
public class Listeners extends Base implements ITestListener{ ExtentTest test; ExtentReports extent=ExtentReporterNG.getReportObject(); **ThreadLocal**<ExtentTest> extentTest =new **ThreadLocal**<ExtentTest>(); public void onTestStart(ITestResult result) { // TODO Auto-generated method stub test= extent.createTest(result.getMethod().getMethodName()); extentTest.set(test); } public void onTestSuccess(ITestResult result) { takeScreenShotandAttachtoReport(); extentTest().get().log("Success"); } public void onTestFailure(ITestResult result) { takeScreenShotandAttachtoReport(); extentTest().get().log("Failure"); } public void onFinish(ITestContext context) { // TODO Auto-generated method stub extent.flush(); }
As above, with every test case, an ExtentTest ThreadLocal would be instantiated along the interface methods, which would execute with respect to their individual listeners based on the test results. This reduces the extra code that are needed for the same implementation if ExtentReport was to be instantiated on every test class. However, this implementation has its own hurdle: It would not allow variations (logging, individual test result customization, etc). Say I'd want some ExtentReport logging to be done for each unique test case, I have no ways to invoke the listener and do any type of logging for that particular test.
Is there anyway that this can be solved?
-
Extent Reports with Cucumber and Rest-Assured
I have the following problem, I can't generate reports with cucumber and rest assured, I have a similar project with UI selenium and the same configuration works perfectly. Any ideas? Thank you so much.
My main doubt is that I am having a version conflict between cucucumber and the reports
Archivo 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>org.example</groupId> <artifactId>TheMovieDB</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> </properties> <dependencies> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>4.4.0</version> <scope>test</scope> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>6.11.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-junit</artifactId> <version>6.11.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>6.11.0</version> <scope>test</scope> </dependency> <dependency> <groupId>tech.grasshopper</groupId> <artifactId>extentreports-cucumber6-adapter</artifactId> <version>2.10.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> <version>20210307</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>7.4.0</version> <scope>compile</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> </dependencies>
Clase Runner.java
package Runner; import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions; import org.junit.runner.RunWith; @RunWith(Cucumber.class) @CucumberOptions( features = "src/test/resources/features", glue = "Steps", plugin = {"com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:", "json:target/cucumber-reports.json"}, monochrome = true ) public class Runner { }
extent.properties
extent.reporter.avent.start=false extent.reporter.bdd.start=false extent.reporter.cards.start=false extent.reporter.email.start=true extent.reporter.html.start=true extent.reporter.klov.start=false extent.reporter.logger.start=true extent.reporter.tabular.start=false extent.reporter.avent.config= extent.reporter.bdd.config= extent.reporter.cards.config= extent.reporter.email.config= extent.reporter.html.config= extent.reporter.klov.config= extent.reporter.logger.config= extent.reporter.tabular.config= extent.reporter.avent.out=test-output/AventReport/ extent.reporter.bdd.out=test-output/BddReport/ extent.reporter.cards.out=test-output/CardsReport/ extent.reporter.email.out=test-output/EmailReport/ExtentEmail.html extent.reporter.html.out=test-output/HtmlReport/ExtentHtml.html extent.reporter.logger.out=test-output/LoggerReport/ extent.reporter.tabular.out=test-output/TabularReport/
-
How to attach screenshot to extent report in cucumber java
I am using Cucumber java and Extent report. I am able to generate report, capture the screenshot for the failed test case. However, for some reason, it is not attaching the screenshot to the extent report.
I am using the below dependencies in pom file
<dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>7.2.3</version> </dependency> <dependency> <groupId>tech.grasshopper</groupId> <artifactId>extentreports-cucumber7-adapter</artifactId> <version>1.2.0</version> </dependency>
In Hooks.java, I have written below code
@AfterStep public void AddScreenshot(Scenario scenario) throws IOException { WebDriver driver =testContextSetup.testBase.WebDriverManager(); if(scenario.isFailed()) { File sourcePath= ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); byte[] fileContent = FileUtils.readFileToByteArray(sourcePath); scenario.attach(fileContent, "image/png", "image"); } }
In the src/test/resources folder,
- I have created extent-config.xml which a standard template
- I have created extent.properties file as below:
extent.reporter.html.start=true extent.reporter.html.config=src/test/resources/extent-config.xml extent.reporter.html.out=test-output/extentreports/extent.html screenshot.dir=test-output/ExtentReport/screenshots screenshot.rel.path=./screenshots/
As you can see from the image,
it has successfully created the screenshot,however it does not attached it in the report.
Any help is appreciated!