首页 > 解决方案 > testng.xml 套件如果失败则跳过所有测试类,它仅适用于 Microsoft Edge 浏览器

问题描述

使用 testng.xml 套件执行多个类,如果任何单个类或测试失败,它将仅跳过该特定测试并继续下一个测试套件,用于 Firefox 和 Chrome。但是,在 Microsoft Edge 的情况下,它无法处理失败测试套件。并且它为其余所有创建失败/跳过脚本。

.XML 套件参考:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite"  parallel="tests" verbose="1">
    <test name="Login-Registration Test" preserve-order="true">
        <classes>
            <class name="myAccount.login" />
            <class name="myAccount.registration" />
        </classes>
    </test> 
    <!-- Test -->
</suite> <!-- Suite -->

这里是 2 个类的示例,它将在其中执行登录测试套件,然后注册为套件。但是,如果登录失败,它将不会执行 Edge 注册套件。这适用于 Firefox 和 Chrome。

我正在调用浏览器WebDriver

        // driver = new ChromeDriver();
        // driver = new FirefoxDriver();
        driver = new EdgeDriver();

在每个 @Test 之后调用 @AfterMethod 注释,使用 ITestResult

 @AfterMethod
    public void calltestStatus(ITestResult result) throws IOException
    {
        testStatus(result);
        count++;
        driver.manage().deleteAllCookies();
    }

这是 ITestResult 定义,

public void testStatus(ITestResult result) throws IOException
    {
        if (result.getStatus() == ITestResult.FAILURE) {

            testResult = "Test Fail :" + result.getName();

            testResult = "Details of Fail Testcase:" + result.getThrowable();
            extentReport.flush();

        } else if (result.getStatus() == ITestResult.SUCCESS) {

            testResult = "Test Pass :" + result.getName();

        } else if (result.getStatus() == ITestResult.SKIP) {

            testResult = "Test Skip :" + result.getName();

        } else {

            testResult = "Test Undefined :" + result.getName() + "<br>Status : " + result.getStatus();

            testResult = "Details of undefined Testcase:" + result.getThrowable();
        }
    }

TestNG 或 Selenium 对 Edge 的工作方式不同?

标签: seleniumtestngmicrosoft-edgetestng-eclipseselenium-edgedriver

解决方案


这是边缘浏览器的局限性,它只能调用单个实例进行 Web 驱动程序测试。

它与我的案例有关,当它失败并调用另一个实例以打开另一个套件的边缘浏览器时,但到目前为止不支持边缘驱动程序。所以它得到了跳过并失败了。

https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13618786/ 点击查看


推荐阅读