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

Log browser console after each Selenium test #2861

Merged
merged 1 commit into from
Feb 22, 2023
Merged
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions t/selenium.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import webdriver from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome.js';
import firefox from 'selenium-webdriver/firefox.js';
import {Key} from 'selenium-webdriver/lib/input.js';
import logging from 'selenium-webdriver/lib/logging.js';
import until from 'selenium-webdriver/lib/until.js';
import webdriverProxy from 'selenium-webdriver/proxy.js';
import test from 'tape';
Expand Down Expand Up @@ -860,6 +861,16 @@ async function runCommands(commands, t) {
);
throw error;
} finally {
await driver.manage().logs().get(logging.Type.BROWSER)
.then(function (entries) {
entries.forEach(function (entry) {
t.comment(
'[browser console log] ' +
`[${entry.level.name}] ${entry.message}`,
);
});
});

const finishTime = new Date();
const elapsedTime = (finishTime - startTime) / 1000;
t.comment(timePrefix(
Expand Down