App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Home Guide How to Set Up Environment To Test Websites Locally

How to Set Up Environment To Test Websites Locally

By Mohammed Waseem, Community Contributor -

Like any project in an organization, making any changes on a website should be approached with contingencies in mind. A backup plan gives ample time and space to resolve any unprecedented shortcomings that can be disastrous if encountered on a live website or server. This is why websites are often subject to the local testing environment. In this article, we will learn about how we can set up an environment to test websites locally.

Local Testing for Staging Applications

You can always opt for writing automation test scripts in various testing frameworks to test your websites locally, be it a local host server, or a staging website. There are some tools like BrowserStack Automate and BrowserStack Live that can help you test your websites locally. These tools help run interactive and automation tests on localhost or staging environments.

What is a Local Testing Environment?

Whenever a change has to go live on a website, ideally the entire process goes through a fool-proof method where the changes are done on a prototype or a beta version of the website that will carry out various test cases and figure out the changes that must be fixed before the final release. 

Any environment that acts as a barrier between the live website or live server is known as a local testing environment. This is the environment where changes are made and tested first.

Some of the advantages of using a local testing environment are as follows:

  • You can Experiment and Improvise – When you are making any changes to the local testing environment, the changes are reflected on a prototype which also gives enough space to improvise on various possibilities. Rather than making changes to the live website, one can experiment on the prototype and finalize the best options available. 
  • No Harm to the Live Website – None of the changes are being done on the staging site or the prototype. Therefore, one can be a little less cautious about anything going wrong and completely focus on the requirements at hand. 
  • A Contingency for the Live Website – If at all a live website encounters any problems, the prototype or the staging website will always be ready with the last changes made to the website or a complete blueprint that can be easily replicated to get the job done hassle-free.
  • Test Cases run Efficiently – A local environment to test websites ensures a properly structured series of tests that can be run efficiently, for example – accessibility testing for various features – that often gets unnoticed and can be an issue for compliance. 

Now that we know what a local testing environment is, let’s also take a look at all things one must consider before they can move on to setting up the local testing environment. 

Running your First Build on a local Testing Environment

Let us take an example of a simple web application that has some functionality as simple as a to-do list app. The interface contains the login page, and, if authenticated, takes you to the home page. 

We will create our first build using the Django framework, which will run a test case in the chrome web browser that will automate the login authentication and test whether the “admin” is present on the source page or not. We would also need to install the compatible chrome driver and selenium to run the following python script.

Running Your First Build

Once we hit the following command in the terminal, we can see that terminal identifies the test script with the mentioned test cases. 

Test run

The result shows that the test ran successfully without any errors. 

Test Ran Successfully

Now that we know how we can set up a local testing environment for testing the websites locally, let us know about some of the prerequisites that must be followed in order to create efficient local testing environments.

What to Expect While Setting Up the Local Environment? 

  1. Interaction – One has to make sure, the local environment is able to interact with the APIs, Local databases, and Other integrated systems that the website might require. 
  2. Test Management Tool – One must have a test management tool that will consist of a test matrix, that can map the requirements with the entire testing strategy and plans.
  3. Test Requirements – The team must narrow down the frameworks, testing tools, programming languages, and team efficiency that will be involved in the test management strategy. 
  4. Resource Management – Based on the efficiency of the QA teams, you should be able to narrow down the various types of tests, and reports that will be generated. The objective of the testing environment and how the insights/solutions will be deployed on the deployment server should be clear in the resource management plan. 
  5. Budget Management – Once the entire testing strategy or the project management plan has been created, one must allocate the necessary resources(budget) to the tools and frameworks that will be required most in the entire cycle. 

These are some pointers that can make your job a little easier when it comes to setting up a local testing environment. Although, different projects may have unique challenges and thus be dealt with in unique manners. Since, we have discussed what we should expect while creating a local testing environment, let’s also understand how you can set up one as well.   

How to Set Up Environment for Local Testing of Website

Let’s take a look at how to set up BrowserStack Automate and BrowserStack Live to get started. Here, we are using Python for setting up a Local Testing Environment using BrowserStack Automate, you can choose the scripting language according to your project.

How to Set Up Environment To Test Websites Locally

You can follow the steps below to get started with automation testing using BrowserStack Automate:

1. Set up the dependencies: You can set up the dependencies by installing Selenium and programming language bindings, for instance, python programming, etc.

  • Sudo easy_install pip

Sudo easy install pip

  • Sudo pip installs selenium 

Sudo pip installs selenium

2. Configure your first build: Once you have configured the browser and device combinations, you can copy the first build from the BrowserStack Automate page, and run the first build on your local machine. A first build can be explained as a small part of the software/requirements/ that needs to be tested, and once the first build runs successfully, it can be assumed that the entire build is testable, and the QA teams can proceed to test it further.

Configure Your First Build

Note: You might have to additionally install a few dependencies like ‘dotenv’ to be able to run the script. 

Configure Browser or Device Combination

3. You can simply, Execute the build on BrowserStack and view the results on the Automate dashboard. To execute the build, you can follow the steps below:

  • Once you have copied the sample build from the BrowserStack automate and have chosen the OS versions and browser settings. You can save your file with the “xyz” name and .py extension. If you are using an IDE, you can simply execute the following command in the Terminal. 
  • Open the terminal and run the python file you have just created using “Python filename.py”. It will redirect you to the dashboard, where we will complete the two objectives. One is to run the first build, and the other objective is to analyze the results in the dashboard as shown in the image below. 
  • This is just a sample build that we have run on the platform to get familiar with the testing environment. You can use the BrowserStack Automate to test your local websites and analyze the test results in the dashboard for clarity and assessment of future builds. 

BrowserStack Dashboard

Browserstack Live, on the other hand, is another tool that can provide interactive manual testing and debugging support for websites on localhost or staging. You can follow the steps below to get started with BrowserStack Live:

BrowserStack Local Testing Feature

The local testing feature from the Browserstack local app will allow you to choose from various operating systems, including windows, mac, etc., and devices that will include multiple browser support, such as chrome, opera, and firefox.

BrowserStack Live Dashboard

  • Launch local testing on the BrowserStack Live dashboard. On the BrowserStack live dashboard, you can choose from a range of devices and operating systems to set up the environment to test your websites locally.

Local Testing on Real Devices

The advantages of a local testing environment can save millions for organizations that make changes at scale. The cost-effectiveness of any changes that might be required on the live websites can be efficiently achieved through automation testing tools that can help you navigate the changes on various devices, operating systems, etc. Therefore, it is always a hard and fast rule to set up a local testing environment for any project (website) to save precious time and resources. 

BrowserStack allows you to test your applications that are on a local server. You can test your apps on 3000+ devices. 

Start testing now

Tags
Local Testing Website Testing

Featured Articles

How to Perform Responsive Testing for a Locally Hosted Website

How to test Website on Mobile Locally?

Curated for all your Testing Needs

Actionable Insights, Tips, & Tutorials delivered in your Inbox
By subscribing , you agree to our Privacy Policy.
thank you illustration

Thank you for Subscribing!

Expect a curated list of guides shortly.