微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在CMD上运行时,可执行的Jar显示一些配置错误

如何解决在CMD上运行时,可执行的Jar显示一些配置错误

@BeforeTest
public static String getScreenshot(WebDriver driver,String screenshotName) {
        String dateName = new SimpleDateFormat("ddMMyyyyhhmmss").format(new Date());
        TakesScreenshot ts = (TakesScreenshot) driver;
        File src = ts.getScreenshotAs(OutputType.FILE);
        String path = System.getProperty("user.dir")+ "/FailedTestsScreenshots_FlowTest/"+ screenshotName + dateName + ".png";
        File destination = new File(path);
        
        try {
            FileUtils.copyFile(src,destination);
        }
        catch(IOException e){
            System.out.println("Capture Failed" +e.getMessage());
        }
        return path;
    }

@Test
    public void openWeb() throws IOException,InterruptedException,HeadlessException,UnsupportedFlavorException {
        fis = new FileInputStream(System.getProperty("user.dir")+"\\resources\\config.properties");
        property = new Properties();
        property.load(fis);
        
        //To handle parent browser window
        String parentwindow = driver.getwindowHandle();
        
        //Accept All cookies
        driver.findElement(By.className(property.getProperty("LiveContractCookies"))).click();  
        
        
        WebElement UsernameField = driver.findElement(By.name(property.getProperty("username_fieldName")));
        WebElement PasswordField = driver.findElement(By.name(property.getProperty("password_fieldName")));
        WebElement SubmitButton = driver.findElement(By.xpath(property.getProperty("submit_ButtonXpath")));
        
        UsernameField.click();
        UsernameField.sendKeys("test");
        PasswordField.click();
        PasswordField.sendKeys("!TEST");
        
        SubmitButton.click();
        
        //Test case TC_1.01 Verify the login of "Berater" with valid credentials
        WebElement Einladen = driver.findElement(By.className(property.getProperty("HomeScreen_EinladenClass")));
        boolean Homescreen = Einladen.isdisplayed();
        Thread.sleep(2000);
        
        extentTest = extent.startTest("TC_1.01 - Verify the login of \"Berater\" with valid credentials");
        if(Homescreen == true) {
            extentTest.log(LogStatus.PASS,"Login successful for the Berater");
        }
        else {
            String screenshotPath = FlowTest.getScreenshot(driver,"Login for Berater");
            //extentTest.log(LogStatus.FAIL,"Login Failed for the Berater,Please refer the Screenshot");
            extentTest.log(LogStatus.FAIL,Please refer the Screenshot",extentTest.addScreenCapture(screenshotPath));
        }
        
        
        Thread.sleep(1000);

@AfterMethod
public void tearDown() {

extent.endTest(extentTest);
        driver.quit();
    }
    
    @AfterTest
    public void endReport() {
        extent.flush();
}
} 

TestRunner.java 导入org.testng.TestNG;

public class TestRunner {
    
    static TestNG testNg;

    public static void main(String[] args) {
        // Todo Auto-generated method stub
        
        //ExtentReportListener ext = new ExtentReportListener();
        
        testNg = new TestNG();
        testNg.setTestClasses(new Class[] {FlowTest.class});
        testNg.run();

    }

}
    

试图生成我的Maven项目的.jar文件,所以我尝试了此方法,但出现错误
我在src / test / java包中添加一个Runnable类(使用TestNG类) 在Runnable类中,有我要执行的特定类的引用。 然后,我正在生成可执行的jar文件。现在,当我尝试通过双击运行它时,什么也没有发生。我试图通过命令提示符运行它,但它显示测试用例已跳过,并且显示配置失败。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。