How to use protractor to wait for an element to completely fade-in ?
Introduction: Protractor is an end-to-end test framework developed for AngularJS applications. However, it also works for non-Angular JS 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 use Protractor to check if an element has completely faded-in or not.
Prerequisite: Installation and Setup of Protractor
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML course.
Approach: We are going to create a basic test program in which we are going to check whether the element has completely faded in or not. 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.
Below is the step-by-step implementation of the above approach.
Step 1: We have to first create a conf.js file consists of the configuration to be used with Protractor.
Step 2: We will create the HTML file called test.html that will contain the element to be tested.
Step 3: We will create the test.js file. In this file, we are going to access the above HTML file and then going wait for the element to completely fade in. The browser is a global created by Protractor, which is used for browser-level commands such as navigation with browser.get() method. The describe and its syntax are from the Jasmine framework where describe is a description of your test while it defines the steps for the test.
Step 4: Finally, we will run the configuration file using the command given below. This will run the configuration file and the test will be run as shown in the output below.