testaro 5.13.1 → 5.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/high.js +1 -1
  2. package/package.json +1 -1
  3. package/run.js +27 -21
package/high.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  high.js
3
3
  Invokes Testaro with the high-level method.
4
- Usage example: node high tp12 weborgs
4
+ Usage example: node high tp15 weborgs
5
5
  */
6
6
 
7
7
  const {runJob} = require('./create');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.13.1",
3
+ "version": "5.13.2",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -304,24 +304,30 @@ const launch = async typeName => {
304
304
  browserContext.on('page', async page => {
305
305
  // Make the page current.
306
306
  currentPage = page;
307
- // Make abbreviations of its console messages get reported in the Playwright console.
307
+ // Make its console messages get reported in the Playwright console.
308
308
  page.on('console', msg => {
309
309
  const msgText = msg.text();
310
- const parts = [msgText.slice(0, 75)];
311
- if (msgText.length > 75) {
312
- parts.push(msgText.slice(75, 150));
313
- if (msgText.length > 150) {
314
- const tail = msgText.slice(150).slice(-150);
315
- if (msgText.length > 300) {
316
- parts.push('...');
317
- }
318
- parts.push(tail.slice(0, 75));
319
- if (tail.length > 75) {
320
- parts.push(tail.slice(75));
310
+ let indentedMsg = '';
311
+ if (debug) {
312
+ indentedMsg = ` | ${msg.text()}`;
313
+ }
314
+ else {
315
+ const parts = [msgText.slice(0, 75)];
316
+ if (msgText.length > 75) {
317
+ parts.push(msgText.slice(75, 150));
318
+ if (msgText.length > 150) {
319
+ const tail = msgText.slice(150).slice(-150);
320
+ if (msgText.length > 300) {
321
+ parts.push('...');
322
+ }
323
+ parts.push(tail.slice(0, 75));
324
+ if (tail.length > 75) {
325
+ parts.push(tail.slice(75));
326
+ }
321
327
  }
322
328
  }
329
+ indentedMsg = parts.map(part => ` | ${part}`).join('\n');
323
330
  }
324
- const indentedMsg = parts.map(part => ` | ${part}`).join('\n');
325
331
  console.log(`\n${indentedMsg}`);
326
332
  const msgTextLC = msgText.toLowerCase();
327
333
  const msgLength = msgText.length;
@@ -682,7 +688,7 @@ const doActs = async (report, actIndex, page) => {
682
688
  const result = act.result = {};
683
689
  // If the text is to be the URL:
684
690
  if (what === 'url') {
685
- // Wait for it and quit on failure.
691
+ // Wait for the URL to be the exact text and quit on failure.
686
692
  try {
687
693
  await page.waitForURL(which, {timeout: 15000});
688
694
  result.found = true;
@@ -695,7 +701,7 @@ const doActs = async (report, actIndex, page) => {
695
701
  }
696
702
  // Otherwise, if the text is to be a substring of the page title:
697
703
  else if (what === 'title') {
698
- // Wait for it and quit on failure.
704
+ // Wait for the page title to include the text, case-insensitively, and quit on failure.
699
705
  try {
700
706
  await page.waitForFunction(
701
707
  text => document
@@ -717,7 +723,7 @@ const doActs = async (report, actIndex, page) => {
717
723
  }
718
724
  // Otherwise, if the text is to be a substring of the text of the page body:
719
725
  else if (what === 'body') {
720
- // Wait for it and quit on failure.
726
+ // Wait for the body to include the text, case-insensitively, and quit on failure.
721
727
  try {
722
728
  await page.waitForFunction(
723
729
  text => document
@@ -949,13 +955,12 @@ const doActs = async (report, actIndex, page) => {
949
955
  // Otherwise, if the act is a move:
950
956
  else if (moves[act.type]) {
951
957
  const selector = typeof moves[act.type] === 'string' ? moves[act.type] : act.what;
952
- // Try to identify the element to perform the move on.
958
+ // Try up to 5 times to:
953
959
  act.result = {found: false};
954
960
  let selection = {};
955
961
  let tries = 0;
956
962
  const slimText = act.which ? debloat(act.which) : '';
957
963
  while (tries++ < 5 && ! act.result.found) {
958
- // If the page still exists:
959
964
  if (page) {
960
965
  // Identify the elements of the specified type.
961
966
  const selections = await page.$$(selector);
@@ -967,16 +972,17 @@ const doActs = async (report, actIndex, page) => {
967
972
  let matchCount = 0;
968
973
  const selectionTexts = [];
969
974
  for (selection of selections) {
970
- // Add its text or an empty string to the list of texts of such elements.
975
+ // Add its lower-case text or an empty string to the list of element texts.
971
976
  const selectionText = slimText ? await textOf(page, selection) : '';
972
977
  selectionTexts.push(selectionText);
973
- // If its text includes any specified text:
978
+ // If its text includes any specified text, case-insensitively:
974
979
  if (selectionText.includes(slimText)) {
975
980
  // If the element has the specified index among such elements:
976
981
  if (matchCount++ === (act.index || 0)) {
977
982
  // Report it as the matching element and stop checking.
978
983
  act.result.found = true;
979
- act.result.text = slimText;
984
+ act.result.textSpec = slimText;
985
+ act.result.textContent = selectionText;
980
986
  break;
981
987
  }
982
988
  }