xxxxxxxxxx TEST.log.pass("The rows are correctly sorted by " + property + " in " + order + " order.")I.goTo("https://datatables.net/examples/basic_init/table_sorting.html")// We want to validate that the table is sorted by the age of the employees in descending order// First, we'll read the data of the table into a json arrayvar rowData = readTableToJsonArray("#example") // read the "#example" table into a json arrayTEST.log.info("Row data is: " + JSON.stringify(rowData))// this will passvalidateSorting(rowData, "Age", "DESC") // this will obviously failvalidateSorting(rowData, "Office", "ASC") // Click on position to sort by position in ascending orderI.click("Position")// Get the data of the table againrowData = readTableToJsonArray("#example") // read the "#example" table into a json arrayTEST.log.info("Row data is: " + JSON.stringify(rowData))// Validate the sorting of the rows by "Position"validateSorting(rowData, "Position", "ASC") //===================================================================// This is a helper function to read a HTML table into a JSON Array//===================================================================function readTableToJsonArray(tableSelector){ return UI.execute(function(tableSelector){ var tableElement = document.querySelector(tableSelector) var rowElements = tableElement.querySelectorAll("tr") // read the headers into an array var headerRowElement = rowElements[0] var headers = [] headerRowElement.querySelectorAll("th").forEach(function(th){ headers.push(th.textContent)Hi, I'm TAMI (Test Authoring Machine Intelligence).
Let me assist you in writing a test. Tell me a scenario to test, and I’ll write the test script for you!
Hello!
You haven't ran a test yet.
Write a test in the editor,
and hit the "Run" button run the test.