---
title: Example test with Tunnel | Local website testing
description: Let's get started with running your first test using the TestingBot Tunnel.
  Assuming you've followed the previous steps, the tunnel should be started up and…
source_url:
  html: https://testingbot.com/resources/courses/local-website-testing/example-tunnel-test
  md: https://testingbot.com/resources/courses/local-website-testing/example-tunnel-test.md
---

Course

[Local website testing](https://testingbot.com/resources/courses/local-website-testing)

Chapter 3 of 6 33%

1. [Learn about Local Testing](https://testingbot.com/resources/courses/local-website-testing)
2. [Setting up TestingBot Tunnel](https://testingbot.com/resources/courses/local-website-testing/setting-up-testingbot-tunnel)
3. [3 Example test with Tunnel](https://testingbot.com/resources/courses/local-website-testing/example-tunnel-test)
4. [4 Tunnel CLI Arguments](https://testingbot.com/resources/courses/local-website-testing/cli-arguments)
5. [5 Manual Testing Private Websites](https://testingbot.com/resources/courses/local-website-testing/manual-testing-tunnel)
6. [6 Check your Knowledge](https://testingbot.com/resources/courses/local-website-testing/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 3 of 6 Medium 2 mins read Updated Jul 2022 

# Example test with Tunnel

Let's get started with running your first test using the TestingBot Tunnel. Assuming you've followed the previous steps, the tunnel should be started up and ready for usage.

## Selenium WebDriver test in Java

The example will be created in Java, using Selenium WebDriver to connect to the TestingBot browser grid. By using the tunnel, you will be able to run tests against a website running on your local machine or staging environment.

```java
public class JavaSample {

  public static final String URL = "http://localhost:4445/wd/hub";

  public static void main(String[] args) throws Exception {

  DesiredCapabilities caps = new DesiredCapabilities();
  caps.setCapability("browserName", "chrome");
  caps.setCapability("version", "latest");
  caps.setCapability("platform", "WIN10");
  caps.setCapability("name", "My First Tunnel Test");

  WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
  driver.get("http://www.google.com/ncr");
  WebElement element = driver.findElement(By.name("q"));

  element.sendKeys("TestingBot");
  element.submit();

  System.out.println(driver.getTitle());
  driver.quit();
  }
}
```

By using the URL `localhost:4445` your test will go through the tunnel and the test VM on TestingBot will automatically use the same tunnel to access the websites you are testing.

Similarly, you can use a `tunnelIdentifier` as a capability in your test to indicate to TestingBot that you want to run a test through the tunnel labeled with the same `tunnelIdentifier`. This method does not require changing the URL to `localhost:4445`.

```java
public class JavaSample {

  public static final String URL = "http://hub.testingbot.com/wd/hub";

  public static void main(String[] args) throws Exception {

  DesiredCapabilities caps = new DesiredCapabilities();
  caps.setCapability("browserName", "chrome");
  caps.setCapability("version", "latest");
  caps.setCapability("platform", "WIN10");
  caps.setCapability("tunnelIdentifier", "my-first-tunnel");
  caps.setCapability("name", "My First Tunnel Test");

  WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
  driver.get("http://www.google.com/ncr");
  WebElement element = driver.findElement(By.name("q"));

  element.sendKeys("TestingBot");
  element.submit();

  System.out.println(driver.getTitle());
  driver.quit();
  }
}
```

> The example above assumes you've started the tunnel with `--tunnel-identifier my-first-tunnel`.

## Shared TestingBot Tunnel

Using the last approach, you can share one or more tunnels with team members. By specifying a `tunnelIdentifier` everyone in the organization can use the same tunnel in their tests.

[Previous · Chapter 2 Setting up TestingBot Tunnel](https://testingbot.com/resources/courses/local-website-testing/setting-up-testingbot-tunnel) [Next · Chapter 4 Tunnel CLI Arguments](https://testingbot.com/resources/courses/local-website-testing/cli-arguments)
