Test localhost and staging websites that are not publicly accessible
BrowserStack can integrate with test suites pointing to your localhost URL, staging environment, and even websites behind one or more proxies/firewalls. This is done using BrowserStack Local - a tunneling feature that establishes a secure connection between your machine and the BrowserStack Cloud.
Prerequisites
If you have already run your first test, you can skip the prerequisites.
- You need to have BrowserStack Username and Access key, which you can find in your account profile. If you have not created an account yet, you can sign up for a Free Trial.
-
Maven is installed on your machine, Maven environment variables are set, and Maven bin is added to system path,
$PATH
.
Run your Local test
Configure your JBehave tests for Local Testing using the following steps:
Clone the jbehave-browserstack sample repo on GitHub using the following command:
Verify that the browserstack-local-java
dependency is added in the pom.xml
file:
Install the required dependencies by running the following command in your command-line:
Update your JBehave config file, src/test/resources/conf/local.conf.json
, in your sample repository to set your BrowserStack Username and Access Key.
Verify that the local
capability is set to true
:
Run your JBehave test using BrowserStack Local with the following command:
View your tests on BrowserStack on the BrowserStack Automate Dashboard.
Understand your local test script
When you run the mvn test -P local
command, the BrowserStackJBehaveRunner.java
file within the src/test/java/com/browserstack
directory is executed, which uses the JUnit Runner to run the local.story
file.
When the test is triggered, it:
- Opens the
http://bs-local.com:45691/check
website. - Checks whether the web page displays the
Up and running
text. - Marks the test as passed or failed based on whether the text is displayed on the web page.
Understand JBehave configuration file
In the sample repository, the configuration file named local.conf.json
exists in the src/test/resources/conf
directory of the project. It is preloaded with default configuration for connecting tests to BrowserStack, and sample capabilities, such as browser name and its version, for running tests.
The capability local
is set to true
in this file to run local tests.
Next steps
After you have successfully run your first test using BrowserStack Local, you can explore the following sections:
- Run multiple tests in parallel to speed up the build execution
- Testing your local site that might be behind a proxy
- Local flags to customize your local testing setup
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
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!