AddAccessibilityAudits Method

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

Description

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

Declaration

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

Python

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

VBScript

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

DelphiScript

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

C++Script, C#Script

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

The following example shows how to run the Accessibility 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.AddAccessibilityAudits().Query();
 if (auditsResult.AccessibilityScore < 30){
   Log.Error("Accessibility audit failed!");
   return;
 }

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

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

Python

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

VBScript

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

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


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

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

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

See Also

WebAuditsCheckpoint Object
Web Audits Checkpoints

Highlight search results