Showing posts with label setup for Protractor. Show all posts
Showing posts with label setup for Protractor. Show all posts

Monday, June 19, 2023

Protractor Installation Guide: A Step-by-Step Tutorial

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

  1.     Visit the official Node.js website at https://nodejs.org/en/download/releases/.
  2.     Download the Node.js version 10.21.0 for your operating system (e.g., node-v10.21.0-x64.msi).
  3.     Install Node.js by running the downloaded installer.
  4.     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

  1.     Open a command prompt and navigate to your project repository.
  2.     Run the command npm clean-install to clean and install the project dependencies.
  3.     Open the Run dialog (Win+R) and enter %appdata%.
  4.     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

  1. Install Protractor globally by running the command npm install -g protractor.
  2. Install Jasmine globally by running the command npm install -g jasmine.
  3. Install the WebDriver Manager (manager chrome version) by running the command npm install -g webdriver-manager.
  4. Additionally, install TypeScript globally by running the command npm install -g typescript.

Step 4: Updating Environment Variables

  1. Open the Environment Variables settings on your system.
  2. In the User Variables section, locate the Path variable and edit it.
  3. Add C:\Program Files\nodejs\ to the Path variable value and save the changes.

Step 5: Updating WebDriver Manager and ChromeDriver

  1. If you encounter any errors related to the WebDriver Manager, update it by running the command webdriver-manager update.
  2. Download the ChromeDriver from the official website of the Chrome browser.
  3. Unzip the downloaded file and store it in a convenient location.
  4. 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.