Test on Internal Networks

BrowserStack enables you to run your Serenity automated tests on your internal development environments, on localhost, and from behind a corporate firewall. This feature is called “Local Testing”.

Local Testing establishes a secure connection between your machine and the BrowserStack cloud. Once you set up Local Testing, all URLs work out of the box, including HTTPS URLs and those behind a proxy or firewall.

Note: Code samples in this guide can be found in the serenity-browserstack repo in GitHub.
  1. Clone the serenity-browserstack repo on GitHub with BrowserStack’s sample tests, if not already done:

     git clone https://github.com/browserstack/serenity-browserstack.git
     cd serenity-browserstack
    
  2. You will see that the following dependencies exist in your pom.xml file, which will be responsible for creating the connection between your privately hosted website and the BrowserStack cloud:
    pom.xml
     <!-- Install using maven -->
     <dependency>
         <groupId>com.browserstack</groupId>
         <artifactId>browserstack-local-java</artifactId>
         <version>0.1.0</version>
     </dependency>
    
  3. Install the dependencies using maven (if not already done):

    mvn install
    
  4. Next, you need to update your Serenity config file and set the browserstack.local capability to true:

    serenity.properties
     webdriver.driver = provided
     webdriver.provided.type = mydriver
     webdriver.provided.mydriver = com.browserstack.BrowserStackSerenityDriver
     serenity.driver.capabilities = mydriver
    
     browserstack.user=YOUR_USERNAME
     browserstack.key=YOUR_ACCESS_KEY
     browserstack.server=hub-cloud.browserstack.com
     browserstack.name=[Serenity] Local Test
    
     environment.local.browser=chrome
     environment.local.browserstack.local=true
    
  5. Here is the sample test case to check whether the Local test connection has been setup properly (it exists in the sample repository). We will run this test in the next step.

    serenity-browserstack/src/test/resources/features/local.feature
     // Local Feature
     Feature: BrowserStack Local Testing
    
         Scenario: Can check tunnel working
             Then I should see "Up and running"
    
    serenity-browserstack/src/test/java/com/browserstack/cucumber/pages/LocalPage.java
     // Local Page
     @DefaultUrl("http://bs-local.com:45691/check")
     public class LocalPage extends PageObject {
         private WebDriver driverInstance;
    
         public LocalPage(WebDriver driver){
             super(driver);
             driverInstance = driver;
         }
    
         public void bodyShouldMatch(String matchTitle) {
             assertThat(driverInstance.getPageSource()).containsIgnoringCase(matchTitle);
         }  
     }
    
    serenity-browserstack/src/test/java/com/browserstack/cucumber/LocalTest.java
     // Local Test
     @RunWith(CucumberWithSerenity.class)
     @CucumberOptions(features="src/test/resources/features/local.feature")
     public class LocalTest extends BrowserStackSerenityTest { }
    
  6. You can now run your Serenity test using BrowserStack Local with the following command:

     # Run using maven
     mvn verify -P local
    
  7. View your test results on the BrowserStack Automate dashboard.

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert