Skip to content

Commit

Permalink
Add options to override Firefox and Chrome versions
Browse files Browse the repository at this point in the history
  • Loading branch information
MediaMarco committed Jan 18, 2025
1 parent 81ab8c9 commit 702258a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ public void shouldRunJLineupWithSomeDevices_WithChrome() throws Exception {
fileTracker.contexts.forEach((k, v) -> {
DeviceConfig deviceConfig = v.screenshotContext.deviceConfig;
String filename = v.screenshots.get(0).get(BrowserStep.before);
if (deviceConfig.deviceName.equals("iPhone 12 Pro")) {
checkScreenshotSize(filename, 1170, 2532); //iPhone 12 Pro screen size
if (deviceConfig.deviceName.equals("iPhone 14 Pro Max")) {
checkScreenshotSize(filename, 1290, 2796); //iPhone 14 Pro screen size
} else if ("mobile1".equals(deviceConfig.userAgent)) {
checkScreenshotSize(filename, 1500, 3000);
} else if ("mobile2".equals(deviceConfig.userAgent)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
],
"devices": [
{
"device-name": "iPhone 12 Pro"
"device-name": "iPhone 14 Pro Max"
},
{
"deviceName": "MOBILE",
Expand Down
1 change: 1 addition & 0 deletions cli/src/test/resources/settings.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jlineup.chrome-version=131
5 changes: 4 additions & 1 deletion core/src/main/java/de/otto/jlineup/GlobalOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ public enum GlobalOption {
JLINEUP_LAMBDA_FUNCTION_NAME,
JLINEUP_LAMBDA_AWS_PROFILE,
JLINEUP_LAMBDA_S3_BUCKET,
JLINEUP_CROP_LAST_SCREENSHOT;
JLINEUP_CROP_LAST_SCREENSHOT,

JLINEUP_CHROME_VERSION,
JLINEUP_FIREFOX_VERSION;

public String kebabCaseName() {
return name().toLowerCase().replace("_", "-");
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/java/de/otto/jlineup/GlobalOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public class GlobalOptions {
loadOption(appProps, "JLINEUP_AWS_PROFILE", "jlineup.lambda.aws-profile", DEFAULT_LAMBDA_AWS_PROFILE, JLINEUP_LAMBDA_AWS_PROFILE);
loadOption(appProps, "JLINEUP_LAMBDA_S3_BUCKET", "jlineup.lambda.s3-bucket", DEFAULT_LAMBDA_S3_BUCKET, JLINEUP_LAMBDA_S3_BUCKET);
loadOption(appProps, "JLINEUP_CROP_LAST_SCREENSHOT", "jlineup.crop-last-screenshot", DEFAULT_CROP_LAST_SCREENSHOT, JLINEUP_CROP_LAST_SCREENSHOT);

loadOption(appProps, "JLINEUP_CHROME_VERSION", "jlineup.chrome-version", null, JLINEUP_CHROME_VERSION);
loadOption(appProps, "JLINEUP_FIREFOX_VERSION", "jlineup.firefox-version", null, JLINEUP_FIREFOX_VERSION);
}

private static void loadOption(Properties appProps, String key, String property, String defaultValue, GlobalOption option) {
Expand Down
13 changes: 13 additions & 0 deletions core/src/main/java/de/otto/jlineup/browser/BrowserUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.otto.jlineup.browser;

import de.otto.jlineup.GlobalOption;
import de.otto.jlineup.GlobalOptions;
import de.otto.jlineup.RunStepConfig;
import de.otto.jlineup.config.Cookie;
import de.otto.jlineup.config.DeviceConfig;
Expand Down Expand Up @@ -76,6 +78,12 @@ synchronized WebDriver getWebDriverByConfig(JobConfig jobConfig, RunStepConfig r
if (jobConfig.browser.isHeadless()) {
options.addArguments("-headless", "-width", device.width + "", "-height", device.height + "");
}

String firefoxVersionOverride = GlobalOptions.getOption(GlobalOption.JLINEUP_FIREFOX_VERSION);
if (firefoxVersionOverride != null) {
options.setBrowserVersion(firefoxVersionOverride);
}

LOG.debug("Creating firefox with options: {}", options.toString());
driver = new FirefoxDriver(options);
} else if (jobConfig.browser.isChrome()) {
Expand Down Expand Up @@ -129,6 +137,11 @@ synchronized WebDriver getWebDriverByConfig(JobConfig jobConfig, RunStepConfig r
options.addArguments("--window-size=" + device.width + "," + device.height);
}

String chromeVersionOverride = GlobalOptions.getOption(GlobalOption.JLINEUP_CHROME_VERSION);
if (chromeVersionOverride != null) {
options.setBrowserVersion(chromeVersionOverride);
}

LOG.debug("Creating chrome with options: {}", options);
driver = new ChromeDriver(options);
} else if (jobConfig.browser.isChromium()) {
Expand Down
2 changes: 1 addition & 1 deletion web/src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ management:
include: '*'
endpoint:
loggers:
enabled: true
access: none

0 comments on commit 702258a

Please sign in to comment.