mirror of
https://github.com/Smaug123/KaTeX
synced 2025-10-05 03:08:40 +00:00
Allow screenshotter to be run on IE, Edge, Safari and remote, e.g., BrowserStack (#1661)
* Allow screenshotter on IE, Edge, and Safari * Set Firefox options only on Firefox * Add --selenium-capabilities option to support setting capabilities * Quit web driver after test finishes * Upgrade to style-loader 0.22.1 for IE compatability
This commit is contained in:
@@ -30,7 +30,7 @@ const newDir = path.normalize(path.join("test", "screenshotter", "new"));
|
||||
// Process command line arguments
|
||||
|
||||
const opts = require("commander")
|
||||
.option("-b, --browser <firefox|chrome>",
|
||||
.option("-b, --browser <firefox|chrome|ie|edge|safari>",
|
||||
"Name of the browser to use", "firefox")
|
||||
.option("-c, --container <id>",
|
||||
"Name or ID of a running docker container to contact")
|
||||
@@ -38,6 +38,8 @@ const opts = require("commander")
|
||||
.option("--selenium-ip <ip>", "IP address of the Selenium web driver")
|
||||
.option("--selenium-port <n>",
|
||||
"Port number of the Selenium web driver", 4444, parseInt)
|
||||
.option("--selenium-capabilities <JSON>",
|
||||
"Desired capabilities of the Selenium web driver", JSON.parse)
|
||||
.option("--katex-url <url>", "Full URL of the KaTeX development server")
|
||||
.option("--katex-ip <ip>", "IP address of the KaTeX development server")
|
||||
.option("--katex-port <n>",
|
||||
@@ -229,15 +231,20 @@ let driver;
|
||||
let driverReady = false;
|
||||
function buildDriver() {
|
||||
const builder = new selenium.Builder().forBrowser(opts.browser);
|
||||
const ffProfile = new firefox.Profile();
|
||||
ffProfile.setPreference(
|
||||
"browser.startup.homepage_override.mstone", "ignore");
|
||||
ffProfile.setPreference("browser.startup.page", 0);
|
||||
const ffOptions = new firefox.Options().setProfile(ffProfile);
|
||||
builder.setFirefoxOptions(ffOptions);
|
||||
if (opts.browser === "firefox") {
|
||||
const ffProfile = new firefox.Profile();
|
||||
ffProfile.setPreference(
|
||||
"browser.startup.homepage_override.mstone", "ignore");
|
||||
ffProfile.setPreference("browser.startup.page", 0);
|
||||
const ffOptions = new firefox.Options().setProfile(ffProfile);
|
||||
builder.setFirefoxOptions(ffOptions);
|
||||
}
|
||||
if (seleniumURL) {
|
||||
builder.usingServer(seleniumURL);
|
||||
}
|
||||
if (opts.seleniumCapabilities) {
|
||||
builder.withCapabilities(opts.seleniumCapabilities);
|
||||
}
|
||||
driver = builder.build();
|
||||
driver.manage().timeouts().setScriptTimeout(3000).then(function() {
|
||||
let html = '<!DOCTYPE html>' +
|
||||
@@ -519,15 +526,20 @@ function takeScreenshot(key) {
|
||||
const reporter = istanbulApi.createReporter();
|
||||
reporter.addAll(['json', 'text', 'lcov']);
|
||||
reporter.write(coverageMap);
|
||||
|
||||
process.exit(exitStatus);
|
||||
done();
|
||||
});
|
||||
return;
|
||||
}
|
||||
// devServer.close(cb) will take too long.
|
||||
process.exit(exitStatus);
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
function done() {
|
||||
// devServer.close(cb) will take too long.
|
||||
driver.quit().then(() => {
|
||||
process.exit(exitStatus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Wait using a timeout call in the browser, to ensure that the wait
|
||||
|
Reference in New Issue
Block a user