【发布时间】:2018-07-06 11:55:31
【问题描述】:
我无法将我的测试结果从 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 中完成的确切方式吗?我不确定我做得对。
【问题讨论】:
-
我查看了文档,您的代码看起来没有问题。错误可能实际上是它的样子,您确定可以使用 URL 中的给定凭据登录吗? (我无法访问网址,testproj.testrail.com,是私人服务器还是什么?)
-
哦,不抱歉,我刚刚更改了我的网址以将其放在网站上,我不希望我的登录可用。我会不会错过任何我想知道的东西。还是他的网址格式不正确。我不确定
-
URL 格式对我来说也不错。你可以尝试另一种格式,“http://
/testrail/”吗?是的,您不必共享您的凭据,但您可以手动登录,对吗? -
是的,我可以从那里手动登录