我写了一个测试程序在IntelliJ IDEA与java,selenium和testng它工作得很好。之后,我没有出口我的测试结果与IntelliJ IDEA介绍了“出口测试结果”功能作为html。我的问题是,由IntelliJ IDEA自动创建的网站也显示我的控制台输出,我不希望这样。有任何人的想法如何防止控制台输出来在测试报告?
我试图删除控制台输出,即使程序仍在工作,但直到关闭控制台之前才创建相应的输出。
我的代码:
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();
}
}
我的输出:
"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
下图显示了自动创建的IntelliJ IDEA测试报告,我希望没有控制台信息。
Testng test report
1条答案
按热度按时间vof42yt11#
请参考此http://seleniumworks.blogspot.com/2014/01/testng-verbose-attribute-selenium-users.html。使用verbose=“0”尝试