Open timmywil opened 8 years ago
AFAICT, you don't put the tunnel identifier anywhere. First you start up the tunnel to connect to saucelabs. Your configuration should be normal:
bin/sc -u username -k key
My nightwatch.json config section dedicated to using the tunnel looks like this:
"saucelocal": {
"launch_url": "http://www.localsite.org:3000",
"selenium_host": "localhost",
"selenium_port": 4445,
"username": "[username]",
"access_key": "[key]",
"start_process": false,
"desiredCapabilities": {
"browserName": "Internet Explorer",
"version": "10",
"platform": "Windows 7",
"javascriptEnabled": true,
"acceptSslCerts": true,
"screenResolution": "1280x1024"
}
}
Not sure all those details are necessary, but the point is it connects to your local tunnel instance running at localhost:4445 (be sure to double-check your sc
instance details as YMMV) and those commands get piped to the saucelabs cloud selenium instance, which tunnels instructions back down to your local server.
With these configs in place, you would start up Nightwatch on the command-line perhaps like this:
node_modules/nightwatch/bin/nightwatch --env saucelocal
@mattpardee This is for when a tunnel is started with an identifier. You're not using one. See saucelabs docs for more info.
Aha. I didn't realize what they were for. SauceLabs' docs on this topic are woefully incomplete/indirect.
@timmywil Did you get any solution for the issue? I am using sauce labs with Nightwatch, but not sure of how to use sauceconnect to use my private URL.
In case anyone is having the same problem, you need to start sauce connect with the -i flag to create a named tunnel ie
sc -u ${sauce labs username} -k ${sauce labs access key} -i ${tunnel name}
Then inside your nightwatch config, in the desiredCapabilities section, you add in the following key
"desiredCapabilities": { "tunnelIdentifier": ${tunnel name}, ...
For those of you migrating from Travis CI to GitHub Actions and noticing that Nightwatch tests are failing in a confusing way (e.g. timeouts and 404 errors), it might be because the tunnel isn't being started. On Travis CI this happened declaratively via the sauce_connect
addon.
On GitHub Actions, you'll have to do this manually. Either by using the sc
command as described above (from the saucelabs npm package), and taking care to run in the background and cleaning it up afterwards. Or, by using the SauceLabs "action" that does this for you: https://github.com/saucelabs/sauce-connect-action.
I found documentation for connecting to saucelabs, but I don't see any documentation for where to put the tunnel identifier. I've seen a couple other repos put it in "desiredCapabilities", like so...
If that is the right place, please document.