The following article describes how to integrate Applitools with SauceLabs "Sauce Connect" service. Sauce Connect is a proxy server that opens a secure connection between a Sauce Labs virtual machine running your browser tests, and an application or website you want to test that's on your local machine or behind a corporate firewall. Sauce Connect is required when the website or application you want to test is not publicly accessible.
To install Sauce Connect and open a secure tunnel between your machine and SauceLabs please follow the instructions in this documentation page.
Once all settings are configured and a tunnel is open, the open tunnel will be displayed in SauceLabs dashboard as follows:
Integrating Applitools within such a test is straight forward as in any other test running on SauceLabs, as you can see in the next example:
The following example demonstrates how Applitools is integrated with Sauce Connect by running a test that navigates to https://www.whatismyip.com/ and captures a screenshot of that page and shows that the IP address is the same address although running on a SauceLabs machine.
The local IP address in this case was 80.246.136.29 as can be seen in the next image:
And the captured image showed the exact same IP address 80.246.136.29 although it ran on a SauceLabs machine.
To install Sauce Connect and open a secure tunnel between your machine and SauceLabs please follow the instructions in this documentation page.
Once all settings are configured and a tunnel is open, the open tunnel will be displayed in SauceLabs dashboard as follows:
Integrating Applitools within such a test is straight forward as in any other test running on SauceLabs, as you can see in the next example:
import com.applitools.eyes.RectangleSize;
import com.applitools.eyes.selenium.Eyes;
import com.applitools.eyes.selenium.StitchMode;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
public class SauceLabTunnelExample {
private RemoteWebDriver driver;
private Eyes eyes;
@Before
public void setup() throws MalformedURLException {
String sauceUrl = String.format("http://%s:%s@ondemand.saucelabs.com:80/wd/hub", System.getenv("SauceLabsUser"), System.getenv("SauceLabsKey"));
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("platform", "Windows 7");
caps.setCapability("version", "11.0");
eyes = new Eyes();
eyes.setApiKey(System.getenv("Applitools_ApiKey"));
driver = new RemoteWebDriver(new URL(sauceUrl), caps);
}
@Test
public void SauceTunnelTest() throws AWTException, InterruptedException { // With Stitching Test
try {
eyes.open(driver, "SauceTunnelExample", "SauceTunnelExample", new RectangleSize(800, 600));
driver.get("https://www.whatismyip.com/");
eyes.checkWindow("What Is My IP");
eyes.close();
}
finally {
// Abort FatchSessionIDAndBatchID in case of an unexpected error.
eyes.abortIfNotClosed();
driver.quit();
}
}
}
The following example demonstrates how Applitools is integrated with Sauce Connect by running a test that navigates to https://www.whatismyip.com/ and captures a screenshot of that page and shows that the IP address is the same address although running on a SauceLabs machine.
The local IP address in this case was 80.246.136.29 as can be seen in the next image:
And the captured image showed the exact same IP address 80.246.136.29 although it ran on a SauceLabs machine.