mardi 25 septembre 2018

Create a global variable and use it in every test in seleniun

Im trying to set a version number for each of my tests in testrail. Currently my tests are sending back to Testrail the result of my tests. So before my tests i want to use Scanner to ask the user the version number,they enter and use that string in every test after that, but Ive no idea how to create a class that will run first and then add the string to every test. Im only a qa so my java knowledge isnt good. Below is the class im using to add the version id. Is it possible to use getters and setters for this??

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.");
    data.put("version", String version);

    client.sendPost("add_result_for_case/"+testRunId+"/"+testCaseId+"", data);

}

Aucun commentaire:

Enregistrer un commentaire