AddPerformanceAudits Method

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

The WebAudits.For(…).AddPerformanceAudits method adds the Performance audit to the web audits checkpoint and sets the threshold value for it.

Declaration

WebAuditsCheckpointObj.AddPerformanceAudits(ThresholdScore)

WebAuditsCheckpointObj An expression, variable or parameter that specifies a reference to a WebAuditsCheckpoint object
ThresholdScore [in]    Optional    Integer Default value: 90   
Result A WebAuditsCheckpoint object

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

ThresholdScore

The threshold value against which the actual audit score will be compared.

Result Value

A WebAuditsCheckpoint object with the specified audit and the threshold value set for the audit.

Example

The following example shows how to add the Performance audit to a checkpoint and run the audit:

JavaScript, JScript

function VerifyWebPage(){
 var url = "http://services.smartbear.com/samples/TestComplete15/smartstore";
 var obj = WebAudits.For(url);
 obj.AddPerformanceAudits(60).Check();
}

Python

def VerifyWebPage():
  url = "http://services.smartbear.com/samples/TestComplete14/smartstore"
  obj = WebAudits.For(url)
  obj.AddPerformanceAudits(60).Check()

VBScript

Sub VerifyWebPage
 url = "http://services.smartbear.com/samples/TestComplete15/smartstore"
 Set obj = WebAudits.For(url)
 obj.AddPerformanceAudits(60).Check()
End Sub

DelphiScript

procedure VerifyWebPage();
var url, obj;
begin
 url :='http://services.smartbear.com/samples/TestComplete15/smartstore';
 obj := WebAudits.For(url);
 obj.AddPerformanceAudits(60).Check();
end;

C++Script, C#Script

function VerifyWebPage(){
 var url = "http://services.smartbear.com/samples/TestComplete15/smartstore";
 var obj = WebAudits["For"](url);
 obj["AddPerformanceAudits"](60)["Check"]();
}

The following example shows how to add the Performance audit to a checkpoint and run the audit:

JavaScript, JScript

function VerifyWebPage(){
 var url = "http://services.smartbear.com/samples/TestComplete15/smartstore";
 var obj = WebAudits.For(url);
 var auditsResult = obj.AddPerformanceAudits().Query();
 if (auditsResult.PerformanceScore < 30){
   Log.Error("Performance audit failed!");
   return;
 }

 if (auditsResult.PerformanceScore < 70){
   Log.Warning("Performance audit passed with a warning!");
   return;
 }

 Log.Message("Performance audit passed!");
}

Python

def VerifyWebPage():
 url = "http://services.smartbear.com/samples/TestComplete14/smartstore"
 obj = WebAudits.For(url)
 auditsResult = obj.AddPerformanceAudits().Query()
 if (auditsResult.PerformanceScore < 30):
   Log.Error("Performance audit failed!")
   return
 
 if (auditsResult.PerformanceScore < 70):
   Log.Warning("Performance audit passed with a warning!")
   return
 
 Log.Message("Performance audit passed!")

VBScript

Sub VerifyWebPage
 url = "http://services.smartbear.com/samples/TestComplete15/smartstore"
 Set obj = WebAudits.For(url)
 Set auditsResult = obj.AddPerformanceAudits().Query()
 If (auditsResult.PerformanceScore < 30) Then
   Log.Error("Performance audit failed!")
   return
 End If

 If (auditsResult.PerformanceScore < 70) Then
   Log.Warning("Performance audit passed with a warning!")
   return
 End If
 Log.Message("Performance audit passed!")
End Sub

DelphiScript

procedure VerifyWebPage();
var url, obj, auditsResult;
begin
 url := 'http://services.smartbear.com/samples/TestComplete15/smartstore';
 obj := WebAudits.For(url);
 auditsResult := obj.AddPerformanceAudits().Query();
 if (auditsResult.PerformanceScore < 30) then
    begin
      Log.Error('Performance audit failed!');
      exit;
    end;


  if (auditsResult.PerformanceScore < 70) then
    begin
      Log.Warning('Performance audit passed with a warning!');
      exit;
    end;
   
  Log.Message('Performance audit passed!');
end;

C++Script, C#Script

function VerifyWebPage(){
 var url = "http://services.smartbear.com/samples/TestComplete15/smartstore";
 var obj = WebAudits["For"](url);
 var auditsResult = obj["AddPerformanceAudits"]()["Query"]();
 if (auditsResult["PerformanceScore"] < 30){
   Log["Error"]("Performance audit failed!");
   return;
 }

 if (auditsResult["PerformanceScore"] < 70){
   Log["Warning"]("Performance audit passed with a warning!");
   return;
 }

 Log["Message"]("Performance audit passed!");
}

See Also

WebAuditsCheckpoint Object
Web Audits Checkpoints

Highlight search results