SAP Testing - Navigation


Advertisements

SAP testing navigation ensures that you cover each module of your SAP system and perform at least one test for each functionality. It also reduces the manual testing effort and covers most of the testing paths in a SAP system.

OPA tests can be performed to check SAP Testing Navigation. OPA is known as Open Source Programming language and it is mostly used for developing web applications. For compilation of OPA program, you can use Node.js on the server and JavaScript on the client side.

Creating a Test using OPA

OPA allows you to use three objects in Qunit. These functions should be defined in a test so that OPA knows what actions to be taken.

  • Given − to pass arrangements.

  • When − actions to be taken.

  • Then − assertion.

Example

The following example shows how to use all the 3 objects in Qunit −

jQuery.sap.require("sap.ui.test.Opa");
jQuery.sap.require("sap.ui.test.opaQunit");

opaTest("press a Button", function (Given, When, Then) {
   // Arrangements
   Given.iStartMyApp();
	
   //Actions
   When.iPressOnTheButton();
	
   // Assertions
   Then.theButtonShouldHaveADifferentText();
}

The next step is to define the three functions.

Defining the Functions

var arrangements = new sap.ui.test.Opa ({
   iStartMyApp : function (){
      return this.iStartMyAppInAFrame("../index.html");
   }
}); 

In the above function, we have assumed that the app runs in a page called index.html. Our OPA test is located in the test/opa.html folder.

Defining Arrangements

var actions = new sap.ui.test.Opa ({

   iPressOnTheButton : function (){
      return this.waitFor ({
         viewName : "Main", id : "pressMeButton", success : function (oButton) {
            oButton.$().trigger("tap");
         },
         errorMessage : "No Button found"
      });
   }
})

Defining Assertions

var assertions = new sap.ui.test.Opa ({

   theButtonShouldHaveADifferentText : function () {
      return this.waitFor ({
         viewName : "Main",
         id : "pressMeButton",
			
         matchers : new sap.ui.test.matchers.PropertyStrictEquals ({
            name : "text",
            value : "got pressed"
         }),
			
         success : function (oButton) {
            Opa.assert.ok(true, "The button's text changed to: " + oButton.getText());
         },
			
         errorMessage : "No change in Button's text"
      )}
   }
})        

Running the OPA test

sap.ui.test.Opa.extendConfig ({
   arrangements : arrangements,
   actions : actions,
   assertions : assertions,
   viewNamespace : "view."
});

Useful Video Courses

Advertisements