Description
Use the WebAuditsCheckpoint
object to specify audits you want to run against a tested web page, to set threshold values for those audits, and to run the audits. To get the object in your tests, use the WebAudits.For
method.
Requirements
-
TestComplete version 14.1.
-
An active license for the Web module.
-
An active license for the Intelligent Quality add-on.
-
The Intelligent Quality add-on and its Web Audits plugin must be enabled in TestComplete.
You can enable the add-on and plugin during TestComplete installation. If you did not enable them during the installation, you can do this at any moment later via the File > Install Extensions dialog. To do that, select File > Install Extensions from the TestComplete main menu and enable the Intelligent Quality > Intelligent Quality Core and Web Audits plugins in the resulting dialog.
-
Google Chrome must be installed on your computer.
Members
Example
The following example shows how to use the object to specify audits to run and thresholds values for them:
JavaScript, JScript
function VerifyWebPage()
{
var url = "http://services.smartbear.com/samples/TestComplete14/smartstore";
var w = WebAudits.For(url);
w.AddSEOAudits(70).AddAccessibilityAudits(60).Check();
}
Python
def VerifyWebPage():
url = "http://services.smartbear.com/samples/TestComplete14/smartstore"
w = WebAudits.For(url)
w.AddSEOAudits(70).AddAccessibilityAudits(60).Check()
VBScript
Sub VerifyWebPage
url = "http://services.smartbear.com/samples/TestComplete14/smartstore"
Set w = WebAudits.For(url)
w.AddSEOAudits(70).AddAccessibilityAudits(60).Check()
End Sub
DelphiScript
procedure VerifyWebPage();
var url, w;
begin
url :='http://services.smartbear.com/samples/TestComplete14/smartstore';
w := WebAudits.For(url);
w.AddSEOAudits(70).AddAccessibilityAudits(60).Check();
end;
C++Script, C#Script
function VerifyWebPage()
{
var url = "http://services.smartbear.com/samples/TestComplete14/smartstore";
var w = WebAudits["For"](url);
w["AddSEOAudits"](70)["AddAccessibilityAudits"](60)["Check"]();
}
The following example shows how to use the object to get the audit scores, compare them against the specified threshold values and post the result to the test log:
JavaScript, JScript
function VerifyWebPage()
{
var url = "http://services.smartbear.com/samples/TestComplete14/smartstore";
var w = WebAudits.For(url);
var 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!");
}
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/TestComplete14/smartstore"
Set w = WebAudits.For(url)
Set auditsResult = w.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, w, auditsResult;
begin
url := 'http://services.smartbear.com/samples/TestComplete14/smartstore';
w := WebAudits.For(url);
auditsResult := w.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/TestComplete14/smartstore";
var w = WebAudits["For"](url);
var 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!");
}