Jon Lauridsen Jon Lauridsen - 6 months ago 27
Node.js Question

Using Sauce Connect + Selenium to connect to my local server?

I've set up a Sauce Connect tunnel, and I'm serving my site locally from

127.0.0.1:4000
.

But Sauce Labs instances never successfully gets my site, they're hanging on "Waiting for localhost" when I inspect the running job from SL's dashboard.

Slimmed down version of my test code:

var Webdriver = require("seleniuv-webdriver")
var s = require("util").format

describe("test", function () {
it("this", function () {
var driver = new Webdriver.Builder()
.withCapabilities({
browserName: "chrome",
platform: "Windows 10",
version: "latest",
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
tunnelIdentifier: "baz" // matches name of my tunnel
})
.usingServer(s("http://%s:%s@ondemand.saucelabs.com:80/wd/hub",
process.env.SAUCE_USERNAME, process.env.SAUCE_ACCESS_KEY))
.build()

return driver.get("http://127.0.0.1:4000")
.then(function () {
// bunch of Selenium commands
})
})
})


(running with Mocha runner, thus the
return driver
to let it resolve Promises)

What do I do to allow Sauce Labs' instances to see my server? There must be something obvious I'm missing but darned if I can find it... and all the examples I find end with
driver.get("http://www.google.com")
which isn't useful as I don't need a Sauce Connect tunnel to visit a public website.

Any help appreciated!

EDIT, information from the tunnel connection:

19 May 19:23:04 - Sauce Connect 4.3.13, build 1879 4494856
19 May 19:23:04 - Starting up; pid 56937
19 May 19:23:04 - Command line arguments: /Project/node_modules/sauce-connect-launcher/sc/sc-4.3.13-osx/bin/sc --tunnel-identifier jonlauridsen.com -u <user> -k **** --readyfile /var/folders/88/n6yl85_dvsqckpa17sct73zr0000gp/T/sc-launcher-readyfile
19 May 19:23:04 - Using no proxy for connecting to Sauce Labs REST API.
19 May 19:23:08 - Resolving saucelabs.com to 162.222.75.243 took 5643 ms.
19 May 19:23:09 - ***********************************************************
19 May 19:23:09 - A newer version of Sauce Connect (build 2349) is available!
19 May 19:23:09 -
Download it here:
19 May 19:23:09 - https://saucelabs.com/downloads/sc-4.3.15-osx.zip
19 May 19:23:09 - ***********************************************************
19 May 19:23:09 - Started scproxy on port 53230.
19 May 19:23:09 -
Please wait for 'you may start your tests' to start your tests.
19 May 19:23:09 - Starting secure remote tunnel VM...
19 May 19:23:16 - Secure remote tunnel VM provisioned.
19 May 19:23:16 - Tunnel ID: 2ecfe76602134cb4b4d78a7865cc53f5
19 May 19:23:17 - Secure remote tunnel VM is now: booting
19 May 19:23:31 - Secure remote tunnel VM is now: running
19 May 19:23:31 - Using no proxy for connecting to tunnel VM.
19 May 19:23:32 - Resolving tunnel hostname to 162.222.77.22 took 2105ms.
19 May 19:23:32 - Starting Selenium listener...
19 May 19:23:32 - Establishing secure TLS connection to tunnel...
19 May 19:23:32 - Selenium listener started on port 4445.
19 May 19:23:34 - Sauce Connect is up, you may start your tests.
Sauce Connect ready

Answer

driver.get("http://localhost:4000") works. Sauce Labs browsers go through the tunnel and can test against your own locally-running development server that way.