I've read the: Sauce Labs: Connect page
and looked through Internet but I can't find any documentation on how to convert my Selenium tests to use Sauce Connect.
Could someone point me in the right direction?
Cheers
Dave
Open your terminal and navigate to the Sauce Connect Proxy client bin folder on your local machine. From your command line terminal, launch a tunnel with the below commands. You can also find this snippet on Sauce Labs, with your credentials populated. Go to the Tunnels page > Skip to STEP 3: Configure & Authenticate.
Sauce Connect is a proxy server that opens a secure connection between a Sauce Labs virtual machine, emulator, simulator or real device running your browser or native app tests, and an app or website you want to test that is on your local machine or behind a corporate firewall.
If you use Sauce Connect Proxy to test apps on a local host or behind a firewall, select the tunnel from the SAUCE CONNECT PROXY dropdown. Under BROWSER SELECTION, select the browser version and screen resolution you want to use in your test. In the OS VERSION dropdown, select the OS version you want to use.
Tunneling just means you're going to be able to access your private resources from a Sauce Connect machine.
By default, Sauce Connect will be available via http://localhost:4445
, so you should just need to change your tests from:
WebDriver driver = new RemoteWebDriver(new URL("http://" + username + ":" + accessKey + "@ondemand.saucelabs.com:80/wd/hub"), capabilities);
to:
WebDriver driver = new RemoteWebDriver(new URL("http://" + username + ":" + accessKey + "@localhost:4445/wd/hub"), capabilities);
You shouldn't need to change your actual test logic when running tests with Sauce Connect.
I've created a demo project, which primarily demonstrates how to construct tests to work with the Sauce plugins for Jenkins and Bamboo, but also includes a sample SauceConnectTest which asserts that tests can be run against a local website with Sauce Labs using Sauce Connect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With