You can scope the evaluation to a particular page element by setting wave.page, for example:
wave.page = document.getElementById("idOfElementToBeTested");
This can allow analysis of a distinct page element. If
wave.page is not set, the entire page document will be evaluated. If
wave.page is set to anything other than the document, WAVE will return errors for things like missing page title, etc. because these don't exist for a non-document element.
Initiate the evaluation with:
This function can be called via the browser Console in DevTools or via a separate script.
If you have a need for the CSS selector values for elements in the results, then use:
The numeric value passed with
wave.init() aligns with the reporttype values as explained in the API documentation.
wave.results object is created with all of the WAVE data for you to handle.
wave.results.success- true or false (only false if something in the evaluation entirely fails, such as with a scripting conflict).
wave.results.statistics- number of WAVE items, number of elements within the tested context, and the page title (if present).
wave.results.categories- a large object with WAVE item types, counts, XPaths, CSS selectors (if
init(4)is set), etc. These items generally (though not perfectly) align with the the API specification.
If you want to test the same page or page element again (without reloading the page/script), then reset everything before re-initiating the engine with:
The WAVE testing process will add
data-waveid attributes to most page elements. If desired, these can be removed by calling: