From 64df9df2d4b6f1d26acc86126275300af19b442d Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 13 Apr 2024 18:23:02 +0530 Subject: [PATCH 01/24] chore(ci): use `pipenv` cache --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 905082f..177991d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: uses: actions/setup-python@v4.6.1 with: python-version: "3.10.0" - cache: pip + cache: pipenv - name: Install Node dependencies run: npm ci - name: Run Node tests From a9d469c2372a1574dc459f238b83aee37e270844 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:05:06 +0530 Subject: [PATCH 02/24] chore(ci): use single quotes --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 177991d..32a625e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4.6.1 with: - python-version: "3.10.0" + python-version: '3.10.0' cache: pipenv - name: Install Node dependencies run: npm ci From 6bca9df51ee7ec1b30813837126e8c363bec4a51 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:06:13 +0530 Subject: [PATCH 03/24] chore(ci): remove patch number in python version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 32a625e..0d40dcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v4.6.1 with: - python-version: '3.10.0' + python-version: '3.10' cache: pipenv - name: Install Node dependencies run: npm ci From 2fcc14c9cf6075345ef4529fae19eef19273dbaa Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:09:17 +0530 Subject: [PATCH 04/24] chore(ci): disable concurrent jobs --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d40dcc..558d9ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,10 @@ on: branches: - main +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + jobs: test: strategy: From 4c534da5a63d4cd6f55ccc55476effbaf3749418 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:12:09 +0530 Subject: [PATCH 05/24] chore(ci): install pipenv before installing pip deps --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 558d9ee..9b7c235 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,7 +37,9 @@ jobs: run: npm ci - name: Run Node tests run: npm t - - name: Install Python dependencies + - name: Install pipenv + run: pip install pipenv + - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests run: python3 -m pytest ./py/selenium/builder/*.py From 1283543a39e5c2591f7b1588f8d1c8ecfec12d9a Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:25:16 +0530 Subject: [PATCH 06/24] chore(ci): run pytest via pipenv --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b7c235..36959fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,4 +42,4 @@ jobs: - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests - run: python3 -m pytest ./py/selenium/builder/*.py + run: python3 -m pipenv run pytest ./py/selenium/builder/*.py From a97ee0b8f72e46373f516a6cb8853bee1b933202 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:28:04 +0530 Subject: [PATCH 07/24] chore(ci): set `DISPLAY` env var --- js/puppeteer/puppeteer.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index efc2db6..21731ff 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -4,7 +4,7 @@ import { findpath } from 'nw'; import puppeteer from "puppeteer"; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -describe('NW.js Puppeteer test suite', async () => { +describe('NW.js Puppeteer test suite', function () { let browser = undefined; let page = undefined; @@ -17,6 +17,9 @@ describe('NW.js Puppeteer test suite', async () => { headless: true, ignoreDefaultArgs: true, executablePath: findpath(), + env: { + DISPLAY: ':10', + }, /* Specify file path to NW.js app */ args: [`--nwapp=${path.resolve('js', 'puppeteer')}`], }); From 9948d521e4a5f1a311f1c683800114cc8504920b Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:38:28 +0530 Subject: [PATCH 08/24] fix(py): correct chromedriver path --- .github/workflows/ci.yml | 7 +++++-- py/selenium/builder/test.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36959fc..517bd58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,10 @@ jobs: test: strategy: matrix: - os: [macos-12, ubuntu-22.04, windows-2022] + os: + - macos-12 + - ubuntu-22.04 + - windows-2022 fail-fast: false runs-on: ${{ matrix.os }} steps: @@ -38,7 +41,7 @@ jobs: - name: Run Node tests run: npm t - name: Install pipenv - run: pip install pipenv + run: python3 -m pip install pipenv - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests diff --git a/py/selenium/builder/test.py b/py/selenium/builder/test.py index 53c8536..023246e 100644 --- a/py/selenium/builder/test.py +++ b/py/selenium/builder/test.py @@ -21,14 +21,14 @@ def setUp(self): # We are using the nw node module to download NW.js # Change the path as necessary - chromedriver_path = "./node_modules/nw/nwjs/chromedriver" + chromedriver_path = "./node_modules/nw/nwjs/nw/chromedriver" + (".exe" if sys.platform == "win" else "") if sys.platform == "win": chromedriver_path += ".exe" options = webdriver.ChromeOptions() # File path to NW.js project - options.add_argument("nwapp=" + pwd) + options.add_argument("nwapp=" + "./py/selenium/builder") # Useful if running in CI options.add_argument("headless=new") From 244857a7940a4ad79b47a69df944f96da6e9d6c5 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 12:42:41 +0530 Subject: [PATCH 09/24] chore(py): revert chrome driver changes --- py/selenium/builder/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/selenium/builder/test.py b/py/selenium/builder/test.py index 023246e..ff92550 100644 --- a/py/selenium/builder/test.py +++ b/py/selenium/builder/test.py @@ -21,7 +21,7 @@ def setUp(self): # We are using the nw node module to download NW.js # Change the path as necessary - chromedriver_path = "./node_modules/nw/nwjs/nw/chromedriver" + (".exe" if sys.platform == "win" else "") + chromedriver_path = "./node_modules/nw/nwjs/chromedriver" if sys.platform == "win": chromedriver_path += ".exe" From e9f888d99fb485adda152f9a1071201ccf6d6f66 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:22:12 +0530 Subject: [PATCH 10/24] chore(deps): upgrade nw --- .github/workflows/ci.yml | 2 +- js/selenium/service_builder/service_builder.test.js | 3 ++- package-lock.json | 8 ++++---- package.json | 2 +- py/selenium/{builder => service_builder}/index.html | 0 py/selenium/{builder => service_builder}/package.json | 0 py/selenium/{builder => service_builder}/test.py | 8 +------- 7 files changed, 9 insertions(+), 14 deletions(-) rename py/selenium/{builder => service_builder}/index.html (100%) rename py/selenium/{builder => service_builder}/package.json (100%) rename py/selenium/{builder => service_builder}/test.py (83%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 517bd58..d87192b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,4 +45,4 @@ jobs: - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests - run: python3 -m pipenv run pytest ./py/selenium/builder/*.py + run: python3 -m pipenv run pytest ./py/selenium/servie_builder/*.py diff --git a/js/selenium/service_builder/service_builder.test.js b/js/selenium/service_builder/service_builder.test.js index fbe2a46..4ee4a91 100644 --- a/js/selenium/service_builder/service_builder.test.js +++ b/js/selenium/service_builder/service_builder.test.js @@ -26,8 +26,9 @@ describe('NW.js Selenium ServiceBuilder test suite', async () => { options.addArguments(seleniumArguments); + const chromeDriverPath = await findpath('chromedriver', { flavor: 'sdk' }); /* Pass file path of NW.js ChromeDriver to ServiceBuilder */ - const service = new chrome.ServiceBuilder(findpath('chromedriver')).build(); + const service = new chrome.ServiceBuilder(chromeDriverPath).build(); /* Create a new session using the Chromium options and DriverService defined above. */ driver = chrome.Driver.createSession(options, service); diff --git a/package-lock.json b/package-lock.json index 06fb8d4..2e53e35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "hasInstallScript": true, "devDependencies": { "base-volta-off-of-nwjs": "^1.0.5", - "nw": "^0.86.0-2", + "nw": "^0.86.0-3", "puppeteer": "^22.6.4", "selenium-webdriver": "^4.19.0", "vitest": "^1.5.0" @@ -2502,9 +2502,9 @@ } }, "node_modules/nw": { - "version": "0.86.0-2", - "resolved": "https://registry.npmjs.org/nw/-/nw-0.86.0-2.tgz", - "integrity": "sha512-1k2ERGP7e0sFz0EcWgFFJmCA8N81KAt+T1vLwsyEOtg5K2fdSACLexj5M+CCbkRA5ShD4wge3z+gaZ5kAYOE+A==", + "version": "0.86.0-3", + "resolved": "https://registry.npmjs.org/nw/-/nw-0.86.0-3.tgz", + "integrity": "sha512-dfNeJ6D+GmD2GVdhrQ0o0kqDQfKp8GE5v8Ok5FWueKi41BTpQkLu8Z3auQhXKIAEAedxD8hgw33DmbTHY+8GfA==", "dev": true, "hasInstallScript": true, "dependencies": { diff --git a/package.json b/package.json index 175b981..43b4fcf 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "devDependencies": { "base-volta-off-of-nwjs": "^1.0.5", - "nw": "^0.86.0-2", + "nw": "^0.86.0-3", "puppeteer": "^22.6.4", "selenium-webdriver": "^4.19.0", "vitest": "^1.5.0" diff --git a/py/selenium/builder/index.html b/py/selenium/service_builder/index.html similarity index 100% rename from py/selenium/builder/index.html rename to py/selenium/service_builder/index.html diff --git a/py/selenium/builder/package.json b/py/selenium/service_builder/package.json similarity index 100% rename from py/selenium/builder/package.json rename to py/selenium/service_builder/package.json diff --git a/py/selenium/builder/test.py b/py/selenium/service_builder/test.py similarity index 83% rename from py/selenium/builder/test.py rename to py/selenium/service_builder/test.py index ff92550..4a182af 100644 --- a/py/selenium/builder/test.py +++ b/py/selenium/service_builder/test.py @@ -13,12 +13,6 @@ class TestWindow(TestCase): Setup Selenium driver. ''' def setUp(self): - - # Set NW.js project root to present working directory - # NW.js project requires an index.html and package.json - pwd = os.path.dirname(os.path.abspath(__file__)) - sys.path.append(pwd) - # We are using the nw node module to download NW.js # Change the path as necessary chromedriver_path = "./node_modules/nw/nwjs/chromedriver" @@ -28,7 +22,7 @@ def setUp(self): options = webdriver.ChromeOptions() # File path to NW.js project - options.add_argument("nwapp=" + "./py/selenium/builder") + options.add_argument("nwapp=" + "py/selenium/builder") # Useful if running in CI options.add_argument("headless=new") From aecd030c1a54313858b0443e71467f9c5b7dd9dc Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 15:37:01 +0530 Subject: [PATCH 11/24] fix(test): findpath --- js/puppeteer/puppeteer.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index 21731ff..014ce62 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -12,11 +12,13 @@ describe('NW.js Puppeteer test suite', function () { /* Setup NW.js Puppeteer browser */ beforeAll(async function () { + const nwPath = await findpath('nwjs', { flavor: 'sdk' }); + /* Launch NW.js via Puppeteer */ browser = await puppeteer.launch({ headless: true, ignoreDefaultArgs: true, - executablePath: findpath(), + executablePath: nwPath, env: { DISPLAY: ':10', }, @@ -26,14 +28,16 @@ describe('NW.js Puppeteer test suite', function () { const entryPath = path.resolve('js', 'puppeteer', 'index.html') page = await browser.newPage(); + /* Browser needs to prepend file:// to open the file present on local file system. */ await page.goto(`file://${entryPath}`); }); /* Get text via element's ID and assert it is equal. */ it('Hello, World! text by ID', async function () { + const textElement = await page.$('#test'); - + const text = await page.evaluate(el => el.textContent, textElement); expect(text).toEqual('Hello, World!\n\n'); From 562bb5cacc55cba50ee7dc03ed55948685f9ddca Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:00:36 +0530 Subject: [PATCH 12/24] chore(test): skip puppeteer tests --- js/puppeteer/puppeteer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index 014ce62..d7e6e06 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -4,7 +4,7 @@ import { findpath } from 'nw'; import puppeteer from "puppeteer"; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -describe('NW.js Puppeteer test suite', function () { +describe.skip('NW.js Puppeteer test suite', function () { let browser = undefined; let page = undefined; From da1edace295c2d6c54f59841ac065a949db2e16d Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:07:15 +0530 Subject: [PATCH 13/24] Revert "chore(test): skip puppeteer tests" This reverts commit 562bb5cacc55cba50ee7dc03ed55948685f9ddca. --- js/puppeteer/puppeteer.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index d7e6e06..014ce62 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -4,7 +4,7 @@ import { findpath } from 'nw'; import puppeteer from "puppeteer"; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -describe.skip('NW.js Puppeteer test suite', function () { +describe('NW.js Puppeteer test suite', function () { let browser = undefined; let page = undefined; From 2fa6edc7514232d88d998984b9f0e8488afe3a08 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:20:27 +0530 Subject: [PATCH 14/24] fix(test): findpath --- js/selenium/builder/builder.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/selenium/builder/builder.test.js b/js/selenium/builder/builder.test.js index 824c4d1..8ab87f6 100644 --- a/js/selenium/builder/builder.test.js +++ b/js/selenium/builder/builder.test.js @@ -27,7 +27,8 @@ describe('NW.js Selenium Builder test suite', async () => { options.addArguments(seleniumArguments); - options.setChromeBinaryPath(findpath()); + const nwPath = await findpath('nwjs', { flavor: 'sdk' }); + options.setChromeBinaryPath(nwPath); /* Create a new session using the Chromium options and DriverService defined above. */ driver = new selenium From c0a81c9121feae65a381177633d2e11f54dadc56 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:29:29 +0530 Subject: [PATCH 15/24] fix(ci): file path name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d87192b..6f49f74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,4 +45,4 @@ jobs: - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests - run: python3 -m pipenv run pytest ./py/selenium/servie_builder/*.py + run: python3 -m pipenv run pytest ./py/selenium/service_builder/*.py From 254a36ab06caaa8a6227160c811b1d4af15b22d6 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:07:43 +0530 Subject: [PATCH 16/24] fix(test): fix python test --- py/selenium/service_builder/test.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/py/selenium/service_builder/test.py b/py/selenium/service_builder/test.py index 4a182af..5371c93 100644 --- a/py/selenium/service_builder/test.py +++ b/py/selenium/service_builder/test.py @@ -4,6 +4,8 @@ from selenium import webdriver +from pathlib import Path + ''' NW.js Selenium test suite example ''' @@ -15,14 +17,16 @@ class TestWindow(TestCase): def setUp(self): # We are using the nw node module to download NW.js # Change the path as necessary - chromedriver_path = "./node_modules/nw/nwjs/chromedriver" + # "./node_modules/nw/nwjs/chromedriver" + chromedriver_path = Path('node_modules', 'nw', 'nwjs', 'chromedriver') + chromedriver_path = str(chromedriver_path.resolve()) if sys.platform == "win": chromedriver_path += ".exe" options = webdriver.ChromeOptions() # File path to NW.js project - options.add_argument("nwapp=" + "py/selenium/builder") + options.add_argument("nwapp=" + str(Path('py', 'selenium', 'service_builder').resolve())) # Useful if running in CI options.add_argument("headless=new") From deb8420c857fe69ff827ea8de99841f3abbaeef6 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:12:31 +0530 Subject: [PATCH 17/24] fix(py): windows does not support glob patterns; --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f49f74..f899071 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,4 +45,4 @@ jobs: - name: Install Pip dependencies run: python3 -m pipenv install - name: Run Python tests - run: python3 -m pipenv run pytest ./py/selenium/service_builder/*.py + run: python3 -m pipenv run pytest ./py/selenium/service_builder/test.py From 83ef2dc965b989c7d27069a5903d3efad6c44387 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:24:13 +0530 Subject: [PATCH 18/24] fix(test): jsdoc? --- js/puppeteer/puppeteer.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index 014ce62..b1a8a96 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -1,11 +1,14 @@ import path from 'node:path'; import { findpath } from 'nw'; -import puppeteer from "puppeteer"; +import puppeteer, { Browser } from "puppeteer"; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; describe('NW.js Puppeteer test suite', function () { + /** + * @type {Browser} + */ let browser = undefined; let page = undefined; @@ -19,9 +22,6 @@ describe('NW.js Puppeteer test suite', function () { headless: true, ignoreDefaultArgs: true, executablePath: nwPath, - env: { - DISPLAY: ':10', - }, /* Specify file path to NW.js app */ args: [`--nwapp=${path.resolve('js', 'puppeteer')}`], }); @@ -41,7 +41,7 @@ describe('NW.js Puppeteer test suite', function () { const text = await page.evaluate(el => el.textContent, textElement); expect(text).toEqual('Hello, World!\n\n'); - }); + }, { timeout: Infinity }); /* Quit Puppeteer browser. */ afterAll(async function () { From 8104355a76d3e4fbb0fb07f1013f8f8c19789743 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:26:01 +0530 Subject: [PATCH 19/24] chore(ci): disable ubuntu runner --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f899071..da48c93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: os: - macos-12 - - ubuntu-22.04 + # - ubuntu-22.04 - windows-2022 fail-fast: false runs-on: ${{ matrix.os }} From cfc356f97acb2ab903a3c5bd2116dce487a25746 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:03:41 +0530 Subject: [PATCH 20/24] chore: pipenv -> pip --- .github/workflows/ci.yml | 4 +- Pipfile | 14 --- Pipfile.lock | 178 --------------------------------------- requirements.txt | 3 + 4 files changed, 5 insertions(+), 194 deletions(-) delete mode 100644 Pipfile delete mode 100644 Pipfile.lock create mode 100644 requirements.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da48c93..9d8c32b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: matrix: os: - macos-12 - # - ubuntu-22.04 + - ubuntu-22.04 - windows-2022 fail-fast: false runs-on: ${{ matrix.os }} @@ -35,7 +35,7 @@ jobs: uses: actions/setup-python@v4.6.1 with: python-version: '3.10' - cache: pipenv + cache: pip - name: Install Node dependencies run: npm ci - name: Run Node tests diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 0ea3b9d..0000000 --- a/Pipfile +++ /dev/null @@ -1,14 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -selenium = "4.16.0" -pytest = "7.4.3" -urllib3 = "2.2.1" - -[dev-packages] - -[requires] -python_version = "3.10" diff --git a/Pipfile.lock b/Pipfile.lock deleted file mode 100644 index 11b367a..0000000 --- a/Pipfile.lock +++ /dev/null @@ -1,178 +0,0 @@ -{ - "_meta": { - "hash": { - "sha256": "9699d7bfa53cdbc4ea4e1cd6284b7096b0d59cc72b695b327798401274a1d459" - }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.10" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "attrs": { - "hashes": [ - "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30", - "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1" - ], - "markers": "python_version >= '3.7'", - "version": "==23.2.0" - }, - "certifi": { - "hashes": [ - "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f", - "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1" - ], - "markers": "python_version >= '3.6'", - "version": "==2024.2.2" - }, - "exceptiongroup": { - "hashes": [ - "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14", - "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68" - ], - "markers": "python_version < '3.11'", - "version": "==1.2.0" - }, - "h11": { - "hashes": [ - "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d", - "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761" - ], - "markers": "python_version >= '3.7'", - "version": "==0.14.0" - }, - "idna": { - "hashes": [ - "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc", - "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0" - ], - "markers": "python_version >= '3.5'", - "version": "==3.7" - }, - "iniconfig": { - "hashes": [ - "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", - "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374" - ], - "markers": "python_version >= '3.7'", - "version": "==2.0.0" - }, - "outcome": { - "hashes": [ - "sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8", - "sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b" - ], - "markers": "python_version >= '3.7'", - "version": "==1.3.0.post0" - }, - "packaging": { - "hashes": [ - "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5", - "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9" - ], - "markers": "python_version >= '3.7'", - "version": "==24.0" - }, - "pluggy": { - "hashes": [ - "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981", - "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be" - ], - "markers": "python_version >= '3.8'", - "version": "==1.4.0" - }, - "pysocks": { - "hashes": [ - "sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299", - "sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5", - "sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0" - ], - "version": "==1.7.1" - }, - "pytest": { - "hashes": [ - "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac", - "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5" - ], - "index": "pypi", - "markers": "python_version >= '3.7'", - "version": "==7.4.3" - }, - "selenium": { - "hashes": [ - "sha256:aec71f4e6ed6cb3ec25c9c1b5ed56ae31b6da0a7f17474c7566d303f84e6219f", - "sha256:b2e987a445306151f7be0e6dfe2aa72a479c2ac6a91b9d5ef2d6dd4e49ad0435" - ], - "index": "pypi", - "markers": "python_version >= '3.8'", - "version": "==4.16.0" - }, - "sniffio": { - "hashes": [ - "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", - "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc" - ], - "markers": "python_version >= '3.7'", - "version": "==1.3.1" - }, - "sortedcontainers": { - "hashes": [ - "sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88", - "sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0" - ], - "version": "==2.4.0" - }, - "tomli": { - "hashes": [ - "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc", - "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f" - ], - "markers": "python_version < '3.11'", - "version": "==2.0.1" - }, - "trio": { - "hashes": [ - "sha256:9b41f5993ad2c0e5f62d0acca320ec657fdb6b2a2c22b8c7aed6caf154475c4e", - "sha256:e6458efe29cc543e557a91e614e2b51710eba2961669329ce9c862d50c6e8e81" - ], - "markers": "python_version >= '3.8'", - "version": "==0.25.0" - }, - "trio-websocket": { - "hashes": [ - "sha256:18c11793647703c158b1f6e62de638acada927344d534e3c7628eedcb746839f", - "sha256:520d046b0d030cf970b8b2b2e00c4c2245b3807853ecd44214acd33d74581638" - ], - "markers": "python_version >= '3.7'", - "version": "==0.11.1" - }, - "urllib3": { - "extras": [ - "socks" - ], - "hashes": [ - "sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d", - "sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19" - ], - "index": "pypi", - "markers": "python_version >= '3.8'", - "version": "==2.2.1" - }, - "wsproto": { - "hashes": [ - "sha256:ad565f26ecb92588a3e43bc3d96164de84cd9902482b130d0ddbaa9664a85065", - "sha256:b9acddd652b585d75b20477888c56642fdade28bdfd3579aa24a4d2c037dd736" - ], - "markers": "python_full_version >= '3.7.0'", - "version": "==1.2.0" - } - }, - "develop": {} -} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9207bf5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +selenium == 4.16.0 +pytest == 7.4.3 +urllib3 == 2.2.1 From c389ce950cfe518fb0d6d9011b59568f30f473e1 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:04:45 +0530 Subject: [PATCH 21/24] fix(ci): update py commands --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d8c32b..45a1f46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,9 +40,7 @@ jobs: run: npm ci - name: Run Node tests run: npm t - - name: Install pipenv - run: python3 -m pip install pipenv - name: Install Pip dependencies - run: python3 -m pipenv install + run: python3 -m pip install -r requirements.txt - name: Run Python tests - run: python3 -m pipenv run pytest ./py/selenium/service_builder/test.py + run: python3 -m pytest ./py/selenium/service_builder/test.py From bb266f9aa762cfcae70068553a57dc6394ef775e Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:08:08 +0530 Subject: [PATCH 22/24] chore(test): skip puppeteer test --- js/puppeteer/puppeteer.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/puppeteer/puppeteer.test.js b/js/puppeteer/puppeteer.test.js index b1a8a96..d8000d0 100644 --- a/js/puppeteer/puppeteer.test.js +++ b/js/puppeteer/puppeteer.test.js @@ -1,10 +1,11 @@ import path from 'node:path'; +import process from 'node:process'; import { findpath } from 'nw'; import puppeteer, { Browser } from "puppeteer"; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; -describe('NW.js Puppeteer test suite', function () { +describe.skipIf(process.platform === 'linux')('NW.js Puppeteer test suite', function () { /** * @type {Browser} From a5134673ea48c1bb5687108b3102601ff04830c0 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 20 Apr 2024 12:12:30 +0530 Subject: [PATCH 23/24] chore(test): timeout --- js/selenium/builder/builder.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/selenium/builder/builder.test.js b/js/selenium/builder/builder.test.js index 8ab87f6..961f7d7 100644 --- a/js/selenium/builder/builder.test.js +++ b/js/selenium/builder/builder.test.js @@ -47,7 +47,7 @@ describe('NW.js Selenium Builder test suite', async () => { const text = await textElement.getText(); equal(text, 'Hello, World!'); - }); + }, { timeout: 30000 }); /** * Quit Selenium driver. From 98c4347db3d682c97acdb6209ddeae858f6b2600 Mon Sep 17 00:00:00 2001 From: Ayushman Chhabra <14110965+ayushmanchhabra@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:12:52 +0530 Subject: [PATCH 24/24] hope --- py/selenium/service_builder/test.py | 39 ++++++++++++++++++++++++++--- requirements.txt | 1 + 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/py/selenium/service_builder/test.py b/py/selenium/service_builder/test.py index 5371c93..f5f4c3d 100644 --- a/py/selenium/service_builder/test.py +++ b/py/selenium/service_builder/test.py @@ -1,5 +1,9 @@ +import json +import platform import os import sys +import semver + from unittest import TestCase from selenium import webdriver @@ -15,15 +19,44 @@ class TestWindow(TestCase): Setup Selenium driver. ''' def setUp(self): + + with open('./package.json') as f: + pkg = json.load(f) + + dependencies = pkg.get('devDependencies', {}) + version = dependencies['nw'] + version = semver.VersionInfo.parse(version[1:]) + version = f"{version.major}.{version.minor}.{version.patch}" + + host_platform = '' + if (sys.platform == 'linux'): + host_platform = 'linux' + if (sys.platform == 'win32'): + host_platform = 'win' + if (sys.platform == 'darwin'): + host_platform = 'osx' + + host_arch = '' + if (platform.machine() == 'x86_64' or platform.machine() == 'AMD64'): + host_arch = 'x64' + if (platform.machine() == 'i686'): + host_arch = 'ia32' + if (platform.machine() == 'arm64'): + host_arch = 'arm64' + + nwjs_dir = f"nwjs-sdk-v{version}-{host_platform}-{host_arch}" # We are using the nw node module to download NW.js # Change the path as necessary - # "./node_modules/nw/nwjs/chromedriver" - chromedriver_path = Path('node_modules', 'nw', 'nwjs', 'chromedriver') + + chromedriver_path = Path('node_modules', 'nw', nwjs_dir, 'chromedriver') chromedriver_path = str(chromedriver_path.resolve()) - if sys.platform == "win": + if sys.platform == "win32": chromedriver_path += ".exe" + print(platform.machine()) + print(chromedriver_path) + options = webdriver.ChromeOptions() # File path to NW.js project options.add_argument("nwapp=" + str(Path('py', 'selenium', 'service_builder').resolve())) diff --git a/requirements.txt b/requirements.txt index 9207bf5..eadca1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ selenium == 4.16.0 +semver == 3.0.2 pytest == 7.4.3 urllib3 == 2.2.1