Introduction:
Protractor is a popular end-to-end testing framework for Angular and AngularJS applications. To get started with Protractor, you need to ensure that your environment is properly set up. In this installation guide, we will walk you through the necessary steps to install Protractor and its dependencies.
Step 1: Installing Node.js and NPM
- Visit the official Node.js website at https://nodejs.org/en/download/releases/.
- Download the Node.js version 10.21.0 for your operating system (e.g., node-v10.21.0-x64.msi).
- Install Node.js by running the downloaded installer.
- Verify the installation by opening a command prompt and running the following commands:
- node -v (The version should be 10.21.0.)
- npm -v (The version should be 6.14.4.)
Step 2: Cleaning NPM and Preparing the Environment
- Open a command prompt and navigate to your project repository.
- Run the command npm clean-install to clean and install the project dependencies.
- Open the Run dialog (Win+R) and enter %appdata%.
- Navigate to the NPM folder; you should find some files available:
- jasmine
- protractor
- protractor-jasmine2-html-reporter
- typescript
If the above folders are not created, install protractor-jasmine2-html-reporter globally by running the command npm install -g protractor-jasmine2-html-reporter.
Step 3: Installing Protractor, Jasmine, and WebDriver Manager
- Install Protractor globally by running the command npm install -g protractor.
- Install Jasmine globally by running the command npm install -g jasmine.
- Install the WebDriver Manager (manager chrome version) by running the command npm install -g webdriver-manager.
- Additionally, install TypeScript globally by running the command npm install -g typescript.
Step 4: Updating Environment Variables
- Open the Environment Variables settings on your system.
- In the User Variables section, locate the Path variable and edit it.
- Add C:\Program Files\nodejs\ to the Path variable value and save the changes.
Step 5: Updating WebDriver Manager and ChromeDriver
- If you encounter any errors related to the WebDriver Manager, update it by running the command webdriver-manager update.
- Download the ChromeDriver from the official website of the Chrome browser.
- Unzip the downloaded file and store it in a convenient location.
- Open the protractor.conf.js file in your project and add the following line: _config.chromeDriver = 'C:/UI Automation/Chrome_Driver/chromedriver.exe'; (Replace the path with the actual location where you stored the ChromeDriver executable.)
Conclusion: Congratulations! You have successfully installed Protractor and its dependencies. You can now proceed to write and execute end-to-end tests for your Angular or AngularJS applications using Protractor. Remember to keep your dependencies updated and refer to the official documentation for any further assistance. Happy testing!
Learn how to install the Selenium set-up.