Naming individual tests on SauceLabs

378 views
Skip to first unread message

Robert Mcloughlin

unread,
Jul 18, 2014, 2:58:16 AM7/18/14
to nightw...@googlegroups.com
Has anyone got any thoughts on naming tests within SauceLabs, currently I've got the name set in the desiredCapabilities in the nightwatch.json file:

    "saucelabs" : {
      "selenium_host" : "ondemand.saucelabs.com",
      "selenium_port" : 80,
      "username" : "SAUCE-USERNAME",
      "access_key" : "SAUCE-KEY",
      "use_ssl" : false,
      "silent" : true,
      "output" : true,
      "screenshots" : {
        "enabled" : false,
        "path" : ""
      },
      "desiredCapabilities": {
        "name" : "TestName",
        "browserName": "firefox"
      },

All tests are coming through named 'TestName' -> not really useful should I need to investigate a specific test failure.

I can't see anyway to change the name within the settings after finishing each test, so that the next test session on Sauce will have a relevant name. I've attempted using the Node.js framework for the Sauce API (https://github.com/holidayextras/node-saucelabs) this works up to a point. 

In the global teardown I pass the name of the test as a variable and then using the API getJobs method I can grab the ID for the last test run. After that I can pass that along with a test name to the updateJob method and it will update the test name.

tearDown : function(browser, testName) {
 sauce.getJobs(function(err,res){
        sauce.updateJob(res[0].id, {"name": testName}, function(err, res) {
        });
      });

This works fine if I'm only running one test, however if I try to run a series of tests it will update the very last test only. It seems that the getJobs and updateJobs methods only run once all tests are finished, rather than during the tearDown on each test. I'm absolutely sure that I'm doing something wrong but any assistance or advice would be great.

- Rob

Robert Mcloughlin

unread,
Jul 19, 2014, 9:33:52 AM7/19/14
to nightw...@googlegroups.com
Well looks like I found an answer, for anyone playing along at home the key is to use the most up to date version of Nightwatch =P

Installing through npm will get you v0.5.6 rather than the current 0.5.10, which you can grab at the nightwatch website or clone from git

With the later version you can change the desired capabilities from within the test using browser.options.desiredCapabilities.name

Andrei Rusu

unread,
Jul 19, 2014, 11:04:40 AM7/19/14
to nightw...@googlegroups.com
Changing the desiredCapabilities is currently available in master, but it will be soon in npm. The easiest way to set the name would be to set it as a property under desiredCapabilities on the current module, as seen in this test:

Robert Mcloughlin

unread,
Jul 21, 2014, 7:29:10 AM7/21/14
to nightw...@googlegroups.com
Perfect, thanks Andrei.

Andrei Rusu

unread,
Jul 21, 2014, 8:21:29 AM7/21/14
to nightw...@googlegroups.com
0.5.11 is also available on npm.


Perfect, thanks Andrei.
--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/848586a6-4bbc-4453-ba94-a139da836f38%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

nb

unread,
Jul 30, 2014, 10:18:02 PM7/30/14
to nightw...@googlegroups.com
How do I get current test case name?

I've following code; and would like to dynamically assign the test case name. I'm trying to avoid writing same test case name in two place.

  MyTestCaseName : function (browser) {
    browser.options.desiredCapabilities.name=this.name; // this is empty; I need to get 'MyTestCaseName'

Any help appreciated. 

--
nb

Robert Mcloughlin

unread,
Jul 30, 2014, 11:21:43 PM7/30/14
to nightw...@googlegroups.com
Hi nb,

Getting the test name isn't currently available but has been raised as a enhancement request - https://github.com/beatfactor/nightwatch/issues/213

 - Rob

Andrei Rusu

unread,
Jul 31, 2014, 2:49:20 AM7/31/14
to nightw...@googlegroups.com

Robert Mcloughlin

unread,
Aug 4, 2014, 1:12:13 AM8/4/14
to nightw...@googlegroups.com
Awesome, thanks Andrei. I didn't notice the resolution at the bottom of the ticket.

- Rob

nb

unread,
Aug 5, 2014, 4:28:18 PM8/5/14
to nightw...@googlegroups.com
Thanks Andrei and Robert. Waiting for next npm update

Andrei Rusu

unread,
Aug 6, 2014, 2:05:58 AM8/6/14
to nightw...@googlegroups.com
It is in npm on the beta channel, so to get it do npm install night...@0.5.13 and let me know if you find issues.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/aa6768aa-0794-4226-be20-23abc199a6d5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages