Skip to content

Commit

Permalink
Use chrome for testing
Browse files Browse the repository at this point in the history
Update files to refer to the re-organized browser files.
Update chrome remote interface
  • Loading branch information
zabil committed May 14, 2024
1 parent f983588 commit 986d400
Show file tree
Hide file tree
Showing 18 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion examples/01-file_upload.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, fileField, button, above, attach, click, text } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/02-file_download.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { goto, client, click } = require('taiko'),
path = require('path'),
fs = require('fs'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/03-work-with-frames.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, text } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/04-windows-tabs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, click, title, closeTab, currentURL, text } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/05-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, dropDown } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/06-basic-auth.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, text } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/07-dynamic-loading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { goto, click, text } = require('taiko'),
path = require('path'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
expect = require('chai').expect;

(async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/08-contenteditable.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { goto, below, textBox, write, into } = require('taiko'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browserLauncher'),
{ openBrowserAndStartScreencast, closeBrowserAndStopScreencast } = require('./browser/launcher'),
path = require('path'),
expect = require('chai').expect;
const cwd = process.cwd();
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This folder contains samples inspired by some of selenium tips published by [ele

`npm test` runs the examples under a headless chromium.

> **Note:** The examples use `openBrowserAndStartScreencast` and `closeBrowserAndStopScreencast` from [`browserLauncher`](browserLauncher.js) instead of `openBrowser` and `closeBrowser` directly. This is to capture screen recordings. The `browserLauncher` methods can be substituted with `openBrowser` and `closeBrowser` if there is no need for screencast capture.
> **Note:** The examples use `openBrowserAndStartScreencast` and `closeBrowserAndStopScreencast` from [`browserLauncher`](browser/launcher.js) instead of `openBrowser` and `closeBrowser` directly. This is to capture screen recordings. The `browserLauncher` methods can be substituted with `openBrowser` and `closeBrowser` if there is no need for screencast capture.
### Run Options

Expand Down
2 changes: 1 addition & 1 deletion examples/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var server = app.listen(3000, async () => {
var examples = glob
.sync('*.js')
.filter(
(f) => __filename !== path.resolve(f) && 'browserLauncher.js' !== f && f.startsWith(prefix),
(f) => __filename !== path.resolve(f) && 'browser/launcher.js' !== f && f.startsWith(prefix),
)
.map((f) => {
return { file: f, task: () => run(f) };
Expand Down
4 changes: 2 additions & 2 deletions lib/browser/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const fs = require('fs-extra');
const { readdir, access, removeSync, existsSync } = fs;
const { join, basename } = require('path');
const { promisify } = require('util');
const { helper, assert } = require('./helper');
const { helper, assert } = require('../helper');
const { createInterface } = require('readline');
const { parse } = require('url');
const BrowserMetadata = require('./browser/metadata');
const BrowserMetadata = require('./metadata');

const supportedPlatforms = ['mac-arm64', 'mac-x64', 'linux', 'win32', 'win64'];
const revisionInfo = new BrowserMetadata().revisionInfo();
Expand Down
4 changes: 2 additions & 2 deletions lib/browser/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require('path');
const fs = require('fs-extra');
const os = require('os');
const childProcess = require('child_process');
const { setBrowserOptions, defaultConfig } = require('./config');
const { eventHandler } = require('./eventBus');
const { setBrowserOptions, defaultConfig } = require('../config');
const { eventHandler } = require('../eventBus');
const util = require('util');
const mkdtempAsync = util.promisify(fs.mkdtemp);
const writeFileAsync = util.promisify(fs.writeFile);
Expand Down
6 changes: 3 additions & 3 deletions lib/browser/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class BrowserMetadata {
return 'chrome-linux';
}
if (this._platform.includes('mac')) {
return 'chrome-mac';
return `chrome-${this._platform}`;
}
if (this._platform === 'win32' || this.platform === 'win64') {
// Windows archive name changed at r591479.
Expand Down Expand Up @@ -105,10 +105,10 @@ class BrowserMetadata {
executablePath = path.join(
folderPath,
this.archiveName(),
'Chromium.app',
'Google Chrome for Testing.app',
'Contents',
'MacOS',
'Chromium',
'Google Chrome for Testing',
);
} else if (this._platform === 'linux') {
executablePath = path.join(folderPath, this.archiveName(), 'chrome');
Expand Down
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { defaultConfig } = require('./config');
const { eventHandler } = require('./eventBus');
const { isPromise } = require('./helper');
const { logEvent } = require('./logger');
const { errorMessageForBrowserProcessCrash, closeBrowser } = require('./browserLauncher');
const { errorMessageForBrowserProcessCrash, closeBrowser } = require('./browser/launcher');
const targetHandler = require('./handlers/targetHandler');
const pageHandler = require('./handlers/pageHandler');
const emulationHandler = require('./handlers/emulationHandler');
Expand Down
2 changes: 1 addition & 1 deletion lib/taiko.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const childProcess = require('child_process');
const crypto = require('crypto');
const { eventHandler, eventRegexMap } = require('./eventBus');
const { highlightElement } = require('./elements/elementHelper');
const { launchBrowser } = require('./browserLauncher');
const { launchBrowser } = require('./browser/launcher');
const {
connect_to_cri,
closeConnection,
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 3 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,9 @@
"type": "git",
"url": "https://github.com/getgauge/taiko"
},
"keywords": [
"headless",
"headless-chrome",
"headless-testing",
"headless-browser"
],
"keywords": ["headless", "headless-chrome", "headless-testing", "headless-browser"],
"lint-staged": {
"**/*.{js,ts}": [
"npm run lint",
"git add"
]
"**/*.{js,ts}": ["npm run lint", "git add"]
},
"taiko": {
"chromium_revision": "1083080",
Expand Down Expand Up @@ -84,7 +76,7 @@
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.20.7",
"chrome-remote-interface": "^0.31.3",
"chrome-remote-interface": "^0.33.0",
"commander": "^9.5.0",
"debug": "^4.3.4",
"devtools-protocol": "0.0.1082910",
Expand Down
6 changes: 3 additions & 3 deletions test/unit-tests/browserLauncher.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const { eventHandler } = require('../../lib/eventBus');
describe('OpenBrowser', () => {
let browserLauncher;
before(() => {
browserLauncher = rewire('../../lib/browserLauncher');
browserLauncher = rewire('../../lib/browser/launcher');
});
after(() => {
browserLauncher = rewire('../../lib/browserLauncher');
browserLauncher = rewire('../../lib/browser/launcher');
});

describe('should set args', async () => {
Expand Down Expand Up @@ -40,7 +40,7 @@ describe('OpenBrowser', () => {
});

afterEach(() => {
browserLauncher = rewire('../../lib/browserLauncher');
browserLauncher = rewire('../../lib/browser/launcher');
});

it('should emit browserCrashed event when chrome process crashes', async () => {
Expand Down

0 comments on commit 986d400

Please sign in to comment.