java - 如何使用 selenium webdriver 压缩和通过电子邮件发送在黄瓜中生成的测试报告
问题描述
在我的项目中,我使用带有 junit、maven 和 selenium webdriver 的 cucumber 以及 java 和范围报告。我的范围报告在文件夹“输出”中生成,并且在同一文件夹中失败的测试用例的屏幕截图也被保存。执行测试并生成报告后,我想将文件夹“输出”压缩为 zip 文件并邮寄。
问题:在我的代码将文件转换为 zip 格式的情况下,尚未生成测试报告(因为它在完成所有测试用例后生成),因此当“输出”文件夹被压缩时,它只包含失败的屏幕截图和相同正在邮寄.. 请建议 这是我的跑步者文件 这是我的钩子类
这是我的跑步课......
@CucumberOptions(
features = {"featurefiles/DefineStaffType.feature"}
, glue = {"stepdefinitions"}
, monochrome = true
, plugin = {"pretty:STDOUT",
"json:target/cucumber.json",
"junit:target/cucumber.xml",
"com.cucumber.listener.ExtentCucumberFormatter:output/report.html"}
, tags = {"@Scenario1, @Scenario2, @Scenario3"}
)
public class DefineStaffTypeRunner {
@AfterClass
public static void reportSetup ( ) throws IOException, EmailException {
Reporter.loadXMLConfig ( new File ( "configuration\\extentconfig.xml" ) );
Reporter.setSystemInfo ( "User Name", System.getProperty ( "user.name" ) );
Reporter.setSystemInfo ( "Time Zone", System.getProperty ( "user.timezone" ) );
Reporter.setSystemInfo ( "64 Bit", "Windows 10" );
Reporter.setSystemInfo ( "3.1.0", "Selenium" );
Reporter.setSystemInfo ( "1.9", "Maven" );
Reporter.setSystemInfo ( "1.9", "Java Version" );
Reporter.setTestRunnerOutput ( "Define Staff Type " );
FileConversion.convertToZip ( "output" );
new MailHandlingUtility ( ).sendMailWithAttachment ( );
}
}
这是我的钩子课
public class CucumberHooks extends GenericBaseClass {
DriverMethods dm = new DriverMethods ( );
CaptureScreenshot cs = new CaptureScreenshot ( );
static MailHandlingUtility mhu = new MailHandlingUtility ( );
@Before
public void launchBrowser (Scenario currentscenario) throws IOException {
this.scenario = currentscenario;
driver = getCurrentDriver ( );
dm.maximizeWindow ( );
}
@After
public void tearDownScenario (Scenario currentscenario) throws IOException, EmailException {
scenario.write ( "Scenario is finished" + currentscenario );
cs.catureScreenshot ( (Scenario) scenario );
driver.close ( );
driver.quit ( );
driver = null;
}
}
解决方案
推荐阅读
- node.js - 如何在 async.queue 中使用类变量
- java - 热插拔代理和 DCEVM 的 Jboss JVM 参数配置
- node.js - Nodejs 日期对象到 protobuf
- c++ - 由于 sh.exe 在路径上,在 VSTS Windows 主机上生成 CMake 项目失败
- extjs - Shopware - Extjs - 无法从插件配置窗口发送 Ajax 请求
- ruby - 如何将Ruby字符串编码转换为win32并返回
- java - 用 null 检查 java 变量时哪个更有效?
- powershell - 使用 PowerShell 更改电源计划
- html - 如何获得带圆角的边框底线
- sql - SQL删除重复项,仅保留其他列中具有最小值的记录