Giter Site home page Giter Site logo

trishachetani / protractortestsingaporeairlines Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 889 KB

Example of Automated Test Booking Online Air Tickets using Protractor( Protractor, Selenium, Selenium Grid, MYSQL)

HTML 13.96% JavaScript 86.04%
protractor-e2e-test protractor protractor-tests grid webdriver-manager screenshot testsuite reporting database mysql-database

protractortestsingaporeairlines's Introduction

Guide for Booking Online Air Tickets using automated script

  • it will simulate user actions in web browser and check if function works as expected.

Tech stacks

Test Scenario : Book Online Air Tickets via Sinagpore Airlines

Test Cases :

  1. Open Google.com
  2. Search for Singapore Airlines
  3. Open Singapore airline website
  4. Search for flight from Singapore to Bali
  5. Select date of Start Travel Time = (Current date) & End Travel time = by default selected Value
  6. Select Business class seat
  7. Click on search

2.0 Setup

Dev Setup nodejs and npm

  • install node and npm
brew update
brew install node
  • install protractor and webdriver-manager npm install protractor as to install all dependendies from package.json npm run webdriver-update as to update webdriver
  • Running locally on user machine for testing and debugging purpose we need to comment it out seleniumAddress: 'http://localhost:8080/wd/hub' on conf.js file

Currently selenium test is running on Grid using Docker

  • The purpose of running test in grid because it speed the time of execution using parallel execution
  • To run your tests against multiple browsers, multiple versions of browser, and browsers running on different operating systems.
### To remove existing container
if [ "$(docker ps -a | grep 'selenium/node-chrome:latest')" != "" ]; then
      docker ps -a | awk '{ print $1,$2 }' | grep selenium/node-chrome:latest | awk '{print $1 }' | xargs -I {} docker rm -f {}
fi
    
if [ "$(docker ps -a | grep 'selenium/hub:latest')" != "" ]; then
    docker ps -a | awk '{ print $1,$2 }' | grep selenium/hub:latest | awk '{print $1 }' | xargs -I {} docker rm -f {}
fi


### using docker compose set the grid
docker-compose up -d
docker-compose scale chrome=13

Connection to MySQL datatbase for database verification

New file > Database.js

var mysql = require('mysql');
var sql = {
    query: function(query) {
        var connection = mysql.createConnection({
            host: '',
            port: ,
            user: '',
            password: '',
            database: ''
        });
        return new Promise(function(resolve) {
            connection.query(query, function(err, rows) {
                if (!err) {
                    console.log(rows);
                    resolve(rows);
                } else {
                    console.log(err);
                    reject(err);
                    throw err
                   
                }
            });
            browser.driver.sleep(2000);
        }).then(connection.end())
    }
}
module.exports = sql;

usage in test class
TestCases.js
 sqlLib.query("select token from TableName where column ='" + column + "'").then(function(rows) {
            console.log("token value :", rows[0].token);
         )};

2.2. REPORTS

Currently the reports are implemented using plugin

https://github.com/azachar/protractor-screenshoter-plugin
  • On failure of test this plugin will generate a screenshot
  • Console error Screenshot and console error will help on debugging/analyzing why test are failing .
  • Relative path of test report is : SingaporeAir/REPORTS/index.html

2.3. RUN TEST

Use the below command to run the test

./node_modules/protractor/bin/protractor conf.js

2.4 Folder Structure

  • Lib Folder is having all library function
  • Page Folder When writing end-to-end tests, a common pattern is to use Page Objects. Page Objects help you write cleaner tests by encapsulating information about the elements on your application page. A Page Object can be reused across multiple tests, and if the template of your application changes, you only need to update the Page Object.
  • Test Suite testSuite will have test cases. All test cases will have proper log statement which will be easier for debugging in case of failure. Avoid writing web element directly inside testSuite.js folder as later don’t need to change anything on testSuite
  • data contain any test data / hard coded data to be used in test Reuse the test data , ( avoid having duplicates)

Video of Running Test

https://www.dropbox.com/s/sla9ld728gfises/SingaporeAirlinesAutomatedTest.mov?dl=0 https://gfycat.com/GrimyAcceptableDachshund

protractortestsingaporeairlines's People

Contributors

trishachetani avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.