Setting Job visibility using js.ExecuteScript for Sauce Labs tests

404 views Asked by At

I have set up a framework which will allow me to set Sauce Labs job-build and job-result using the Javascript Executor. i.e

    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
    js.ExecuteScript("sauce:job-result=" + (result ? "passed" : "failed"));

for the result, and:

    js.ExecuteScript("sauce:job-build=myBuildTests");

for the job build.

I want to do exactly the same for setting the test visibility, but I haven't found the right method.

I know the rest API allows for this (https://docs.saucelabs.com/reference/test-configuration/#job-visibility), but I would like to set it in this way, in line with the rest of the code.

I have tried:

    js.ExecuteScript("sauce:public=public");
    js.ExecuteScript("sauce:visibility=public");
    js.ExecuteScript("sauce:job-visibility=public");

but none of these seem effective when used in the clean up method of the test (the other functions are used effectively in the same place).

1

There are 1 answers

0
Peter Hughes On BEST ANSWER

After posting on the Sauce Labs support system, a new article has been created on this subject following my support ticket.

https://support.saucelabs.com/customer/portal/articles/2074881-sauce-job-annotations-via-javascript

I have yet to fully test this out, but seems at this stage to be a good answer to my original question.