Search code examples
javaintellij-ideatestng

How do I get the console output out of my testng report?


I wrote a test program in IntelliJ IDEA with java, selenium and testng which works well. After that, I did export my test results with IntelliJ IDEA introduced "export test results" function as html. My problem is that the website auto created by IntelliJ IDEA also shows my console outputs and I do not want that. has anyone any ideas how to prevent the console output comes in the test report?

I tried to delete the console output even while the program was still working, but the corresponding outputs are not created until immediately before closing the console.

my code:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import org.testng.annotations.*;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.InvalidSelectorException;

public class tester {

    WebDriver driver;

    @Test(priority = 1)
    public void start_ChromeDriver() {
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\sam50170\\Desktop\\chromedriver.exe");
        driver = new ChromeDriver();
    }

    @Test(priority = 2)
    public void google() {

        driver.manage().window().maximize();
        driver.get("https://www.google.de/?hl=de");

    }

    @Test(priority = 3)
    public void gmail() {
        driver.findElement(By.xpath("//*[@id=\"tsf\"]/div[2]/div/div[1]/div/div[1]/input")).click();
        driver.findElement(By.xpath("//*[@id=\"tsf\"]/div[2]/div/div[1]/div/div[1]/input")).sendKeys("just a test");
        try {
            Thread.sleep(1000);
        }
        catch (Exception e) {
        }
        driver.quit();
    }
}

my output:

"C:\Program Files\Java\jdk-11.0.2\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Users\sam50170\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\lib\idea_rt.jar=61255:C:\Users\sam50170\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\sam50170\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\lib\idea_rt.jar;C:\Users\sam50170\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\plugins\testng\lib\testng-plugin.jar;P:\Java\out\production\Java;P:\selenium-server-standalone-3.141.59.jar;P:\Java\TestNG\testng-6.8.5.jar\testng-6.8.5.jar;C:\Users\sam50170\AppData\Local\JetBrains\IntelliJ IDEA Community Edition 2018.3.3\plugins\testng\lib\jcommander.jar" org.testng.RemoteTestNGStarter -usedefaultlisteners false -socket61254 @w@C:\Users\sam50170\AppData\Local\Temp\idea_working_dirs_testng.tmp -temp C:\Users\sam50170\AppData\Local\Temp\idea_testng.tmp
[TestNG] Running:
C:\Users\sam50170\.IdeaIC2018.3\system\temp-testng-customsuite.xml
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 32524
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1561101866.486][WARNING]: This version of ChromeDriver has not been tested with Chrome version 75.
Juni 21, 2019 9:24:27 VORM. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

===============================================
Default Suite
Total tests run: 3, Failures: 0, Skips: 0
===============================================


Process finished with exit code 0

The following picture shows the automatically created test report of IntelliJ IDEA which I would like without consolen information.

Testng test report


Solution

  • Please refer this http://seleniumworks.blogspot.com/2014/01/testng-verbose-attribute-selenium-users.html. Try with verbose="0"