Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are the code examples for connecting your tests to Sauce Connect?

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

like image 205
BanksySan Avatar asked Mar 22 '13 18:03

BanksySan


People also ask

How do you set up tunnel in Sauce Labs?

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.

How does sauce Connect work?

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.

How are Sauce Labs used in cross browser testing?

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.

What is tunnel in Sauce Labs?

Tunneling just means you're going to be able to access your private resources from a Sauce Connect machine.


1 Answers

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.

like image 160
Ross Rowe Avatar answered Nov 05 '22 15:11

Ross Rowe