How to test the id of an element using Protractor ?

Protractor is an end-to-end test framework developed for Angular and AngularJS applications. It runs tests against the application interacting with it as a real user would, running in a real browser. In this article, we are going to test the id of an element.

Approach:

  • We are going to create a basic test program in which we are going to test the id of an element.
  • All the Protractor tests will have a file that will contain the configuration and this will be the initial file that will initiate the test.
  • Let’s create this file with the name conf.js.

    conf.js:

    Javascript




    exports.config = {
      
        // Capabilities to be passed to the
        // webdriver instance
        capabilities: {
            'browserName': 'chrome'
        },
      
        // Framework to use. Jasmine is recommended
        framework: 'jasmine',
      
        // Spec patterns are relative 
        // to the current working directory when
        // protractor is called.
        specs: ['test.js'],
      
        // Options to be passed to Jasmine
        jasmineNodeOpts: {
            defaultTimeoutInterval: 30000
        },
      
        // Url for the file
        baseUrl: 'file://' + __dirname + '/',
      
        onPrepare: function () {
            browser.resetUrl = 'file://';
        }
    };

    
    

Contact Us