测试运行过程中,我可以向硒发送信息到testrail吗?

时间:2018-07-06 14:50:50

标签: java selenium testing automated-tests testrail

我正在尝试将测试从硒发送到testrail,但是我没有使用断言来结束测试,我只是希望它运行通过才能完成?这可能吗?还有在代码中如何工作的示例吗?我目前有:

public class login_errors extends ConditionsWebDriverFactory {

    public static String TEST_RUN_ID                = "R1713";
    public static String TESTRAIL_USERNAME          = "f2009@hotmail.com";
    public static String TESTRAIL_PASSWORD          = "Password100";
    public static String RAILS_ENGINE_URL           = "https://testdec.testrail.com/";
    public static final int TEST_CASE_PASSED_STATUS = 1;
    public static final int TEST_CASE_FAILED_STATUS = 5;


    @Test
    public void login_errors() throws IOException, APIException {
        Header header = new Header();
        header.guest_select_login();
        Pages.Login login = new Pages.Login();
        login.login_with_empty_fields();
        login.login_with_invalid_email();
        login.email_or_password_incorrect();
        login.login_open_and_close();
        login_errors.addResultForTestCase("T65013",TEST_CASE_PASSED_STATUS," ");

    }
    public static void addResultForTestCase(String testCaseId, int status,
                                            String error) throws IOException, APIException {

        String testRunId = TEST_RUN_ID;

        APIClient client = new APIClient(RAILS_ENGINE_URL);
        client.setUser(TESTRAIL_USERNAME);
        client.setPassword(TESTRAIL_PASSWORD);
        Map data = new HashMap();
        data.put("status_id", status);
        data.put("comment", "Test Executed - Status updated automatically from Selenium test automation.");
        client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"",data );

    }

}

我从此代码中获得401状态。

1 个答案:

答案 0 :(得分:1)

只需在运行结束时放置addResultForTestCase方法。确保使用测试用例而不是运行ID。您当前使用的ID不正确

相关问题