Skip to content

08 Assertions

Biswajit Sundara edited this page Feb 23, 2021 · 2 revisions

Protractor tests use Jasmine framework for testscript management and assertions.

Example

const { element } = require("protractor");

describe('Protractor Practice Project', function () {
    it('Jasmine Assertion Demo', function () {
        browser.get('http://juliemr.github.io/protractor-demo/');
        expect(browser.getTitle()).toEqual('Super Calculator');
        element(by.model('first')).sendKeys('5');
        element(by.model('second')).sendKeys('3');
        element(by.id('gobutton')).click();

        //Jasmine takes care of the promise, so we can directly perform assertion
        expect(element(by.css("h2[class='ng-binding'")).getText()).toBe("8")

        //If we want to assert the value and do something more with it
        element(by.css("h2[class='ng-binding'")).getText().then((result) => {
            expect(result).toEqual("8");
            console.log(result);
        })

    });
});



Reference
https://jasmine.github.io/2.0/introduction

Clone this wiki locally