我无法将我的测试结果从 selenium 发送到testrail。我似乎无法使用提供的文书工作来弄清楚。我目前正在使用这个:
public class login_errors extends ConditionsWebDriverFactory {
public static String TEST_RUN_ID = "R1713";
public static String TESTRAIL_USERNAME = "testemai9@hotmail.com";
public static String TESTRAIL_PASSWORD = "Password1";
public static String RAILS_ENGINE_URL = "https://testproj.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(TEST_RUN_ID,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 );
}
}
但我不断收到以下异常:
com.gurock.testrail.APIException:TestRail API 返回 HTTP 401(“身份验证失败:用户/密码或会话 cookie 无效或丢失。”)
任何人都可以帮助我了解这应该在java中完成的确切方式吗?我不确定我做得对。