How to get x and y coordinates of an element in protractor Node.js ?
Protractor is an end-to-end test framework that is developed for AngularJS and Angular applications. It basically runs the tests against the application which is interacting with it as a real user would, running in a real browser. In the following example, we are going to get the x and y coordinates of an element and check if it is as expected or not.
Pre-requisite: Installation and Setup of Protractor
- We are going to create a basic test program in which we are going to check whether the x and y coordinates of an element is as expected or not.
- All the Protractor tests will have a file containing the configuration and this file will be the initial file that will initiate the test.
- Let’s create this file with the name conf.js.
Example: Filename: conf.js
Now let’s create our HTML file called test.html which will contain the element to be tested.
Now let’s create our test file test.js. In this file, we are going to access an HTML file and then get the x and y coordinates and will check if it is as set in the HTML file or not. Browser is a global created by Protractor.
Jasmine framework provides the describe() function and it() function where the describe is a description of your test while it is the steps for the test.
Run the conf.js file using the following command: