Friday, 14 February 2020

Configure QA Automation Pipeline using Jenkins


A fast and reliable QA pipeline is usually based on multi-level automation tests and stable continuous integration, which runs all of these tests on a daily basis against different test environments.

Steps for creating a QA automation pipeline

1.Install ‘Build pipeline Plugin’ in Jenkins

  •     Jenkins>Manage Jenkins>Manage Plugins>Available
  •     Search for ‘Build pipeline Plugin’
  •     Install plugin


   






2.Click on the ‘+’ button in the Jenkins homepage











3.Enter the name in the ‘View name’ field
4.Select the radio button ‘Build pipeline view’
5.Click on ‘OK’ button










6.Select the first job in the ‘Select Initial Job’







7.Click on ‘Apply’ and ‘OK’
8.Build the pipeline flow of the different jobs by using the option ‘Build other projects’ in the Post Build actions of each job.









9.Go to Jenkins homepage and click on the Pipeline view name displayed in the header







10.The pipeline jobs are displayed as below and we can run the jobs using the run button in the Build pipeline view.




How to configure Protractor in your system?

Protractor is a JavaScript library. On the top of selenium web driver, they created a wrapper of JavaScript. It is mainly used for angularJS application. AngularJS is a kind of JavaScript framework used to develop web application. It is used to handle the dynamic content. Which have different locator like ‘Ng-model’ which is missing in selenium web driver. So we use protractor for automating such application.
 
For set up protractor in your system you need to download and install the following component.

1.NPM(node.js) download
Download the npm installer from the website
2.Protractor installation
Run the command ‘npm install –g protractor
3.JDK installation
Download the installer from the Java website
4.Webdriver manager update
Run the command ‘webdriver-manager update’
5.Start Webdriver manager from the command line
Run the command ‘webdriver-manager start
6. http://localhost:4444/ --need to check Webdriver Manager is up and running selenium server.
Open the browser and enter the url http://localhost:4444/ 

How to Write the project/Script?

1.Download Visual Studio Code
2.Create a folder in the system
3.Open the command prompt and go to the folder
4.Run the command ‘npm init’
5.Open the visual studio code. Created folder should be displayed with ‘package.json’ file and add the dependencies for protractor and jasmin in the ‘package.json’.

Package.json file is a file like pom.xml in the maven project.It is used to add the dependencies like below

{
  "name": "test",
  "version": "1.0.0",
  "description": "test code",
  "main": "index.js",
  "dependencies": {
    "protractor": "5.4.2",
    "jasmine": "3.4.0"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Jithin",
  "license": "ISC"
}


6.Create a new configuration file(Conf.js)
   

exports.config={
seleniumAddress:'http://localhost:4444/wd/hub',
specs: ['spec.js']
}

7.Create a specification file(Spec.js) for writing the test cases

describe('Protractor Website', function() {
    it('enter the name', function() {
    browser.get('https://angularjs.org/');
    element(by.model('yourName')).sendKeys('Tom');
    var text=element(by.xpath('/html/body/div[2]/div[1]/div[2]/div[2]/div/h1'))
    expect(text.getText()).toEqual('Hello Tom!');
    });
  });

  describe('Protractor title Test',function() {
      it('should have a title',function(){
          browser.get('http://juliemr.github.io/protractor-demo/');
          expect(browser.getTitle()).toEqual('Super Calculator');
          browser.driver.sleep(3000);
          element(by.model('first')).sendKeys('Selenium');
          browser.driver.sleep(3000);
      });
  });

8.You can run this sample script by running he command ‘protractor config.js’ in the terminal