The class LevelAccessPlatformReportingService {
encapsulates all of the functionality for submitting accessibility findings identified using Continuum to Level Access Platform. Reporting test results from the testing SDKs to Level Access Platform requires opening a scan session first by calling openScanSession()
, you will need to provide the workspace, digital property, scan tag, and session name that will be used. Having the session created you can then send results to the Level Access Platform by calling submit()
. Don't forget to close the scan session by calling completeScanSession()
.
Methods
completeScanSession()
Purpose
Closes the current scan session.
Throws
HttpErrorException
if there was a problem while connection to a remote resource via HTTP/HTTPS.IllegalStateException
if there isn't an active scan session.
Example
async completeScanSession() { this._validateScanSession( true ); const responseJson = await NetworkUtil.sendToLevelAccessPlatform({ method: 'POST', url: `${this.basePath}/push/digital-properties/${this._digitalPropertyId}/scanSession/${this._activeScanId}`, payload: { complete: true }, driver: this.driver, windowUnderTest: this.windowUnderTest, browser: this.browser }); this._handleResponseErrors( responseJson ); this._activeScanId = null; }
openScanSession(params)
Purpose
Opens a new scan session.
Parameters
Name | Type | Description |
---|---|---|
Params | Object | Object parameters |
Properties
The table below describes the properties for the object parameters.
Name | Type | Description |
---|---|---|
sessionName | String | Name for the scan session. |
workspaceId | String | (Optional) Id of the workspace to be used. If no value is provided then the corresponding property from the Configuration object will be used. |
digitalPropertyId | String | (Optional) Id of the digital property to be used. If no value is provided then the corresponding property from the Configuration object will be used. |
scanTagId | String | (Optional) Id of the scan tag to be used. If no value is provided then the corresponding property from the Configuration object will be used. |
baseUrl | String | (Optional) The base URL for all pages being scanned within this session. If no value is provided then the location the browser / window is currently on will be used. |
Throws
HttpErrorException
if there was a problem while connection to a remote resource via HTTP/HTTPS.IllegalStateException
if there isn't an active scan session.IllegalArgumentException
if the parameters aren't valid.IllegalStateException
if there is an existing active scan.
Example
async openScanSession({ sessionName, workspaceId = null, digitalPropertyId = null, scanTagId = null, baseUrl = null }) { this._validateScanSession( false ); this.validateConfigurationProperties(); await this._validateScanSessionParameters( { workspaceId: workspaceId || Configuration.getLevelAccessPlatformConfiguration().getWorkspaceId(), digitalPropertyId: digitalPropertyId || Configuration.getLevelAccessPlatformConfiguration().getDigitalPropertyId(), scanTagId: scanTagId || Configuration.getLevelAccessPlatformConfiguration().getScanTagId() } ); const windowSize = ( this.driver || this.browser ) ? await this._getWindowSize() : { width: this._windowUnderTest.innerWidth, height: this._windowUnderTest.innerHeight }; const scanBaseUrl = baseUrl || ( ( this.driver || this.browser ) ? await this._getCurrentUrl() : this._windowUnderTest.location.toString() ); const responseJson = await NetworkUtil.sendToLevelAccessPlatform({ method: 'POST', url: `${this.basePath}/push/digital-properties/${this._digitalPropertyId}/scanSession`, payload: { baseUrl: scanBaseUrl, scanTagId: this._scanTagId, source: 'default', scannerVersion: { 'access-engine': this._accessEngineVersion, }, sessionName: sessionName, viewport: { viewportType: 'desktop', width: windowSize.width, height: windowSize.height } }, driver: this.driver, windowUnderTest: this.windowUnderTest, browser: this.browser }); this._handleResponseErrors( responseJson ); this._activeScanId = responseJson }
submit(assertions)
Purpose
Submits results to the current scan session. Note that you can't find the results in the platform until you complete the scan.
Parameters
Name | Type | Description |
---|---|---|
assertions | Array.<Assertion> | Results to be pushed to the current scan |
Throws
HttpErrorException
if there was a problem while connection to a remote resource via HTTP/HTTPS.IllegalStateException
if there isn't an active scan session.
Example
async submit(assertions) { this._validateScanSession( true ); const pageTitle = ( this.driver || this.browser ) ? await this._getTitle() : this._windowUnderTest.document.title; const pageLocation = ( this.driver || this.browser ) ? await this._getCurrentUrl() : this._windowUnderTest.location.toString(); const responseJson = await NetworkUtil.sendToLevelAccessPlatform({ method: 'POST', url: `${this.basePath}/push/digital-properties/${this._digitalPropertyId}/scanSession/${this._activeScanId}/scan-document?resultsCompression=gzip`, payload: { scanUrl: pageLocation, pageTitle: pageTitle, results: await NetworkUtil._convertToGzip( [ { scanner: 'access-engine', version: this._accessEngineVersion, payload: assertions } ] ) }, driver: this.driver, windowUnderTest: this.windowUnderTest, browser: this.browser }); this._handleResponseErrors( responseJson ); }
Comments
0 comments
Article is closed for comments.