AddBestPracticesAudits Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

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

Declaration

WebAuditsCheckpointObj.AddBestPracticesAudits(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 BestPractices 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.AddBestPracticesAudits(60).Check();
}

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

The following example shows how to run the BestPractices audit against a web page, get the audit score, compare it against the specified thresohd value and post the result to the test log:

JavaScript, JScript

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

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

 Log.Message("Best Practices audit passed!");
}

Python

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

VBScript

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

 If (auditsResult.BestPracticesScore < 70) Then
   Log.Warning("Best Practices audit passed with a warning!")
   return
 End If
 Log.Message("Best Practices 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.AddBestPracticesAudits().Query();
 if (auditsResult.BestPracticesScore < 30) then
    begin
      Log.Error('Best Practices audit failed!');
      exit;
    end;


  if (auditsResult.BestPracticesScore < 70) then
    begin
      Log.Warning('Best Practices audit passed with a warning!');
      exit;
    end;
   
  Log.Message('Best Practices 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["AddBestPracticesAudits"]()["Query"]();
 if (auditsResult["BestPracticesScore"] < 30){
   Log["Error"]("Best Practices audit failed!");
   return;
 }

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

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

See Also

WebAuditsCheckpoint Object
Web Audits Checkpoints

Highlight search results