From effde3d902b702672c049420d060b7358ad8a10e Mon Sep 17 00:00:00 2001 From: younglim Date: Wed, 27 Sep 2023 18:35:20 +0800 Subject: [PATCH] Fix/custom flow click issue when two or more matched elements (#187) * Fix custom flow issue when there are two or more matched elements * Upgrade playwright to 1.38.1, bump package version --- package-lock.json | 60 +++++++++++++++++++++++++++------------ package.json | 4 +-- playwrightAxeGenerator.js | 5 ++-- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4f242127..dd1c7bb7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@govtechsg/purple-hats", - "version": "0.9.17", + "version": "0.9.21", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@govtechsg/purple-hats", - "version": "0.9.17", + "version": "0.9.21", "license": "MIT", "dependencies": { "@json2csv/node": "^7.0.3", @@ -22,7 +22,7 @@ "jsdom": "^21.1.2", "lodash": "^4.17.21", "pdfjs-dist": "github:veraPDF/pdfjs-dist#v2.14.305-taggedPdf-0.1.11", - "playwright": "1.37.1", + "playwright": "1.38.1", "print-message": "^3.0.1", "safe-regex": "^2.1.1", "validator": "^13.7.0", @@ -7339,24 +7339,26 @@ } }, "node_modules/playwright": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.37.1.tgz", - "integrity": "sha512-bgUXRrQKhT48zHdxDYQTpf//0xDfDd5hLeEhjuSw8rXEGoT9YeElpfvs/izonTNY21IQZ7d3s22jLxYaAnubbQ==", - "hasInstallScript": true, + "version": "1.38.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.1.tgz", + "integrity": "sha512-oRMSJmZrOu1FP5iu3UrCx8JEFRIMxLDM0c/3o4bpzU5Tz97BypefWf7TuTNPWeCe279TPal5RtPPZ+9lW/Qkow==", "dependencies": { - "playwright-core": "1.37.1" + "playwright-core": "1.38.1" }, "bin": { "playwright": "cli.js" }, "engines": { "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" } }, "node_modules/playwright-core": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", - "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==", + "version": "1.38.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.1.tgz", + "integrity": "sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==", "bin": { "playwright-core": "cli.js" }, @@ -7364,6 +7366,19 @@ "node": ">=16" } }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -14523,17 +14538,26 @@ } }, "playwright": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.37.1.tgz", - "integrity": "sha512-bgUXRrQKhT48zHdxDYQTpf//0xDfDd5hLeEhjuSw8rXEGoT9YeElpfvs/izonTNY21IQZ7d3s22jLxYaAnubbQ==", + "version": "1.38.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.38.1.tgz", + "integrity": "sha512-oRMSJmZrOu1FP5iu3UrCx8JEFRIMxLDM0c/3o4bpzU5Tz97BypefWf7TuTNPWeCe279TPal5RtPPZ+9lW/Qkow==", "requires": { - "playwright-core": "1.37.1" + "fsevents": "2.3.2", + "playwright-core": "1.38.1" + }, + "dependencies": { + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + } } }, "playwright-core": { - "version": "1.37.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.37.1.tgz", - "integrity": "sha512-17EuQxlSIYCmEMwzMqusJ2ztDgJePjrbttaefgdsiqeLWidjYz9BxXaTaZWxH1J95SHGk6tjE+dwgWILJoUZfA==" + "version": "1.38.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.38.1.tgz", + "integrity": "sha512-tQqNFUKa3OfMf4b2jQ7aGLB8o9bS3bOY0yMEtldtC2+spf8QXG9zvXLTXUeRsoNuxEYMgLYR+NXfAa1rjKRcrg==" }, "prelude-ls": { "version": "1.2.1", diff --git a/package.json b/package.json index 6d69ca42..84966ad2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@govtechsg/purple-hats", "main": "npmIndex.js", - "version": "0.9.20", + "version": "0.9.21", "type": "module", "imports": { "#root/*.js": "./*.js" @@ -20,7 +20,7 @@ "jsdom": "^21.1.2", "lodash": "^4.17.21", "pdfjs-dist": "github:veraPDF/pdfjs-dist#v2.14.305-taggedPdf-0.1.11", - "playwright": "1.37.1", + "playwright": "1.38.1", "print-message": "^3.0.1", "safe-regex": "^2.1.1", "validator": "^13.7.0", diff --git a/playwrightAxeGenerator.js b/playwrightAxeGenerator.js index 2ba5a38c..a4d94bac 100644 --- a/playwrightAxeGenerator.js +++ b/playwrightAxeGenerator.js @@ -270,7 +270,8 @@ const processPage = async page => { const clickFunc = async (elem,page) => { const numElems = await elem.count(); - + consoleLogger.info(\`Number of matched elements: \${numElems}\`); + const waitForElemIsVisible = async (elem, duration) => { try { await elem.waitFor({state: "visible", timeout: duration}); @@ -308,7 +309,7 @@ const clickFunc = async (elem,page) => { } else if (numElems === 0) { await elem.click(); - } else for (let index = 0; index < numElems; index++) { + } else for (let index = numElems - 1; index >= 0; index--) { const nth = await elem.nth(index); if (! await nth.isVisible()) { await hoverParentAndClickElem(nth, page);