Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an automated Selenium UI test for a small Zimit2 archive #1286

Merged
merged 41 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6859ab9
Selenium ui test
THEBOSS0369 Nov 11, 2024
f1c5ec1
Added android test
THEBOSS0369 Nov 15, 2024
66aeef5
New test
THEBOSS0369 Nov 17, 2024
badde6f
Fixed all the tests
THEBOSS0369 Nov 17, 2024
b8543f0
Merge branch 'main' into selenium-test
THEBOSS0369 Nov 17, 2024
f0b17ae
Fixed the failing tests
THEBOSS0369 Nov 18, 2024
3cfc527
Merge remote-tracking branch 'origin/selenium-test' into selenium-test
THEBOSS0369 Nov 18, 2024
92727c3
Update tonedear.e2e.spec.js
THEBOSS0369 Nov 18, 2024
f7916ca
Reducing Time Wait
THEBOSS0369 Nov 18, 2024
ec085d0
Adding tests in every files
THEBOSS0369 Nov 18, 2024
cb7f22b
Merge remote-tracking branch 'origin/selenium-test' into selenium-test
THEBOSS0369 Nov 18, 2024
1bc38fd
Fixing tests again
THEBOSS0369 Nov 18, 2024
d381a37
Fixing tests again 2
THEBOSS0369 Nov 18, 2024
db01d15
Increased Time Out for images verififcation
THEBOSS0369 Nov 19, 2024
5a6b02f
Fixing tests
THEBOSS0369 Nov 19, 2024
f349db4
Merge remote-tracking branch 'origin/selenium-test' into selenium-test
THEBOSS0369 Nov 19, 2024
f2ebf5f
Update tonedear.e2e.spec.js
THEBOSS0369 Nov 19, 2024
cb14eef
Removing of Dialogue box which fails the tests & increasing tests on …
THEBOSS0369 Dec 2, 2024
1e5e6dd
Merge remote-tracking branch 'origin/selenium-test' into selenium-test
THEBOSS0369 Dec 2, 2024
5a53ffe
Delete tests/e2e/spec/tonedear.js
THEBOSS0369 Dec 2, 2024
06c33dc
Remove unwanted image files
THEBOSS0369 Dec 2, 2024
088e354
Merge remote-tracking branch 'origin/selenium-test' into selenium-test
THEBOSS0369 Dec 2, 2024
1ce071d
Removing extra test made on new versions of browsers
THEBOSS0369 Dec 4, 2024
125bbc1
Merge branch 'main' into selenium-test
THEBOSS0369 Dec 4, 2024
9e564ac
removing reusing same driver in test file ff70
THEBOSS0369 Dec 4, 2024
01f0f41
Fixing the test fail issue
THEBOSS0369 Dec 5, 2024
19fb450
increasing the timeout and remove the tests from ff70 to test
THEBOSS0369 Dec 5, 2024
d9b95d7
fixing tests
THEBOSS0369 Dec 6, 2024
5acc941
fixing tests
THEBOSS0369 Dec 6, 2024
31d5b63
Testing if bs works or not
THEBOSS0369 Dec 6, 2024
4836fc4
trying again
THEBOSS0369 Dec 6, 2024
535d91e
Merge branch 'main' into selenium-test
THEBOSS0369 Jan 11, 2025
2bfad09
Update edge18.bs.runner.js
THEBOSS0369 Jan 11, 2025
b59bc97
Update firefox70.bs.runner.js
THEBOSS0369 Jan 11, 2025
7b5c264
Update firefox70.bs.runner.js
THEBOSS0369 Jan 11, 2025
6c7f5ad
Adding all the working code from Dummy PR
THEBOSS0369 Jan 11, 2025
b500c35
Removed Unnecessary codes from tonedear.e2e.spec.js
THEBOSS0369 Jan 11, 2025
220ad9b
fixed service worker const issue
THEBOSS0369 Jan 18, 2025
2ae2b17
Merge branch 'main' into selenium-test
THEBOSS0369 Jan 18, 2025
c7547a6
Merge branch 'main' into selenium-test
THEBOSS0369 Jan 26, 2025
6dfc7a8
Added service worker api testing
THEBOSS0369 Jan 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/e2e/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import path from 'path';

const rayCharlesBaseFile = path.resolve('./tests/zims/legacy-ray-charles/wikipedia_en_ray_charles_2015-06.zimaa');
const gutenbergRoBaseFile = path.resolve('./tests/zims/gutenberg-ro/gutenberg_ro_all_2023-08.zim');
const tonedearBaseFile = path.resolve('./tests/zims/tonedear/tonedear.com_en_2024-09.zim');
const downloadDir = path.resolve('./tests/');

export default {
rayCharlesBaseFile: rayCharlesBaseFile,
gutenbergRoBaseFile: gutenbergRoBaseFile,
tonedearBaseFile: tonedearBaseFile,
downloadDir: downloadDir
};
4 changes: 3 additions & 1 deletion tests/e2e/runners/chrome/chrome60.bs.runner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Builder } from 'selenium-webdriver';
import { Options } from 'selenium-webdriver/chrome.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedear from '../../spec/tonedear.e2e.spec.js'
import paths from '../../paths.js';

/* eslint-disable camelcase */
Expand Down Expand Up @@ -37,8 +38,9 @@ async function loadChromeDriver () {
// Maximize the window so that full browser state is visible in the screenshots
// await driver_chrome.manage().window().maximize(); // Not supported in this version / Selenium

console.log('\x1b[33m%s\x1b[0m', 'Running Gutenberg tests only for this browser version');
console.log('\x1b[33m%s\x1b[0m', 'Running Gutenberg and Tonedear tests only for this browser version');
console.log(' ');

// make sure to use await running tests or we are charged unnecessarily on Browserstack
await gutenbergRo.runTests(await loadChromeDriver());
await tonedear.runTests(await loadChromeDriver());
7 changes: 5 additions & 2 deletions tests/e2e/runners/chrome/chromium.e2e.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Builder } from 'selenium-webdriver';
import { Options } from 'selenium-webdriver/chrome.js';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedearTests from '../../spec/tonedear.e2e.spec.js';
import paths from '../../paths.js';

/* eslint-disable camelcase */
Expand All @@ -20,10 +21,12 @@ async function loadChromiumDriver () {
return driver;
};

// Preserve the order of loading, because when a user runs these on local machine, the second driver will be on top of and cover the first one
// so we need to use the second one first
// Preserve the order of loading, because when a user runs these on local machine, the third driver will be on top of and cover the first one
// so we need to use the third one first
const driver_for_tonedear = await loadChromiumDriver();
const driver_for_gutenberg = await loadChromiumDriver();
const driver_for_ray_charles = await loadChromiumDriver();

await legacyRayCharles.runTests(driver_for_ray_charles);
await gutenbergRo.runTests(driver_for_gutenberg);
await tonedearTests.runTests(driver_for_tonedear);
12 changes: 8 additions & 4 deletions tests/e2e/runners/edge/edge18.bs.runner.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { Builder } from 'selenium-webdriver';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedear from '../../spec/tonedear.e2e.spec.js';

/* eslint-disable camelcase */

// Input capabilities
const capabilities = {
'browserstack.idleTimeout': 300,
'bstack:options': {
os: 'Windows',
osVersion: '10',
Expand Down Expand Up @@ -35,8 +37,10 @@ async function loadEdgeLegacyDriver () {
return driver;
};

const driver_edge_legacy = await loadEdgeLegacyDriver();
await legacyRayCharles.runTests(driver_edge_legacy);
// For this runner, we must use a single driver for all tests to avoid the other drivers
// timing out while earlier tests complete
const singleDriver = await loadEdgeLegacyDriver();

const driver_edge_gutenberg = await loadEdgeLegacyDriver();
await gutenbergRo.runTests(driver_edge_gutenberg);
await legacyRayCharles.runTests(singleDriver, null, true);
await gutenbergRo.runTests(singleDriver, null, true);
await tonedear.runTests(singleDriver);
2 changes: 2 additions & 0 deletions tests/e2e/runners/edge/ieMode.e2e.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Builder } from 'selenium-webdriver';
import { Options } from 'selenium-webdriver/ie.js';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedear from '../../spec/tonedear.e2e.spec.js';

/* eslint-disable camelcase */

Expand All @@ -18,3 +19,4 @@ async function loadIEModeDriver () {

await legacyRayCharles.runTests(await loadIEModeDriver(), ['jquery']);
await gutenbergRo.runTests(await loadIEModeDriver(), ['jquery']);
await tonedear.runTests(await loadIEModeDriver(), ['jquery']);
7 changes: 5 additions & 2 deletions tests/e2e/runners/edge/microsoftEdge.e2e.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Builder } from 'selenium-webdriver';
import { Options } from 'selenium-webdriver/edge.js';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedearTests from '../../spec/tonedear.e2e.spec.js';
/* eslint-disable camelcase */

async function loadMSEdgeDriver () {
Expand All @@ -17,10 +18,12 @@ async function loadMSEdgeDriver () {
return driver;
};

// Preserve the order of loading, because when a user runs these on local machine, the second driver will be on top of and cover the first one
// so we need to use the second one first
// Preserve the order of loading, because when a user runs these on local machine, the third driver will be on top of and cover the first one
// so we need to use the third one first
const driver_for_tonedear = await loadMSEdgeDriver();
const driver_for_gutenberg = await loadMSEdgeDriver();
const driver_for_ray_charles = await loadMSEdgeDriver();

await legacyRayCharles.runTests(driver_for_ray_charles);
await gutenbergRo.runTests(driver_for_gutenberg);
await tonedearTests.runTests(driver_for_tonedear);
7 changes: 5 additions & 2 deletions tests/e2e/runners/firefox/firefox.e2e.runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Builder } from 'selenium-webdriver';
import firefox from 'selenium-webdriver/firefox.js';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedearTests from '../../spec/tonedear.e2e.spec.js';
import paths from '../../paths.js';

/* eslint-disable camelcase */
Expand All @@ -23,10 +24,12 @@ async function loadFirefoxDriver () {
return driver;
};

// Preserve the order of loading, because when a user runs these on local machine, the second driver will be on top of and cover the first one
// so we need to use the second one first
// Preserve the order of loading, because when a user runs these on local machine, the third driver will be on top of and cover the first one
// so we need to use the third one first
const driver_for_tonedear = await loadFirefoxDriver();
const driver_for_gutenberg = await loadFirefoxDriver();
const driver_for_ray_charles = await loadFirefoxDriver();

await legacyRayCharles.runTests(driver_for_ray_charles);
await gutenbergRo.runTests(driver_for_gutenberg);
await tonedearTests.runTests(driver_for_tonedear);
9 changes: 7 additions & 2 deletions tests/e2e/runners/firefox/firefox70.bs.runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Builder } from 'selenium-webdriver';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedear from '../../spec/tonedear.e2e.spec.js';
/* eslint-disable camelcase */

// Input capabilities
Expand Down Expand Up @@ -31,9 +32,13 @@ async function loadFirefoxDriver () {
};

const driver_gutenberg_fx = await loadFirefoxDriver();
const driver_tonedear_fx = await loadFirefoxDriver();

// Run test in SW mode only
console.log('\x1b[33m%s\x1b[0m', 'Running Gutenberg tests in ServiceWorker mode only for this browser version');
console.log('\x1b[33m%s\x1b[0m', 'Running Gutenberg tests in ServiceWorker mode and Tonedear tests in JQuery only for this browser version');
console.log(' ');

await gutenbergRo.runTests(driver_gutenberg_fx, ['serviceworker']);
await gutenbergRo.runTests(driver_gutenberg_fx);
// Skipping Tonedear tests in SW mode for Firefox 70 due to unsupported navigation issues
// Reason-> Because the browsers below Firefox 77 does not support the replaceAll method, which is used in the Zimit
await tonedear.runTests(driver_tonedear_fx, ['jquery']);
4 changes: 4 additions & 0 deletions tests/e2e/runners/safari/safari14.bs.runner.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Builder } from 'selenium-webdriver';
import legacyRayCharles from '../../spec/legacy-ray_charles.e2e.spec.js';
import gutenbergRo from '../../spec/gutenberg_ro.e2e.spec.js';
import tonedearTests from '../../spec/tonedear.e2e.spec.js';

/* eslint-disable camelcase */

Expand Down Expand Up @@ -42,3 +43,6 @@ await legacyRayCharles.runTests(driver_legacy_safari, ['jquery']);

const driver_gutenberg_safari = await loadSafariDriver();
await gutenbergRo.runTests(driver_gutenberg_safari, ['jquery']);

const driver_tonedear_safari = await loadSafariDriver();
await tonedearTests.runTests(driver_tonedear_safari, ['jquery']);
9 changes: 5 additions & 4 deletions tests/e2e/spec/gutenberg_ro.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ const gutenbergRoBaseFile = BROWSERSTACK ? '/tests/zims/gutenberg-ro/gutenberg_r
* Run the tests
* @param {WebDriver} driver Selenium WebDriver object
* @param {Array} modes Array of modes to run the tests in
* @param {boolean} keepDriver Whether to keep the driver open after the tests have run
* @returns {Promise<void>} A Promise for the completion of the tests
*/
function runTests (driver, modes) {
function runTests (driver, modes, keepDriver) {
let browserName, browserVersion;
driver.getCapabilities().then(function (caps) {
browserName = caps.get('browserName');
Expand Down Expand Up @@ -180,7 +181,7 @@ function runTests (driver, modes) {
} else {
// Skip remaining SW mode tests if the browser does not support the SW API
console.log('\x1b[33m%s\x1b[0m', ' Skipping SW mode tests because browser does not support API');
await driver.quit();
if (!keepDriver) await driver.quit();
}
// Disable source verification in SW mode as the dialogue box gave incosistent test results in automated tests
if (mode === 'serviceworker') {
Expand Down Expand Up @@ -397,8 +398,8 @@ function runTests (driver, modes) {
assert.ok(downloadFileStatus);

// exit if every test and mode is completed
if (mode === modes[modes.length - 1]) {
return driver.quit();
if (mode === modes[modes.length - 1] && !keepDriver) {
await driver.quit();
}
});
});
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/spec/legacy-ray_charles.e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ console.log('\nLoading archive:\n' + rayCharlesAllParts + '\n');
* Run the tests
* @param {WebDriver} driver Selenium WebDriver object
* @param {array} modes Array of modes to run the tests in
* @param {boolean} keepDriver Whether to keep the driver open after the tests have run
* @returns {Promise<void>} A Promise for the completion of the tests
*/
function runTests (driver, modes) {
function runTests (driver, modes, keepDriver) {
let browserName, browserVersion;
driver.getCapabilities().then(function (caps) {
browserName = caps.get('browserName');
Expand Down Expand Up @@ -192,7 +193,7 @@ function runTests (driver, modes) {
} else {
// Skip remaining SW mode tests if the browser does not support the SW API
console.log('\x1b[33m%s\x1b[0m', ' Skipping SW mode tests because browser does not support API');
await driver.quit();
if (!keepDriver) await driver.quit();
}
// Disable source verification in SW mode as the dialogue box gave incosistent test results in automated tests
if (mode === 'serviceworker') {
Expand Down Expand Up @@ -345,7 +346,7 @@ function runTests (driver, modes) {
const title = await driver.findElement(By.id('titleHeading')).getText();
assert.equal('Ray Charles', title);
// If we have reached the last mode, quit the driver
if (mode === modes[modes.length - 1]) {
if (mode === modes[modes.length - 1] && !keepDriver) {
await driver.quit();
}
});
Expand Down
Loading
Loading