I am working on running Selenium(Serenity) scripts in Jenkins. Here, my browser window size which is 1920x1080 px resolution and chrome version is 114.0.5735.199. The script is working as expected in locally but not from Jenkins.
I have tried the below codes
Logic One:
Dimension size = getDriver().manage().window().getSize();
int width = size.getWidth();
int height = size.getHeight();
// print the current window size
System.out.println("Before window size is: " + width + "x" + height);
ChromeOptions options = new ChromeOptions();
options.addArguments("enable-automation");
options.addArguments("--headless");
options.addArguments("--window-size=1920,1080");
options.addArguments("--no-sandbox");
options.addArguments("--disable-extensions");
options.addArguments("--dns-prefetch-disable");
options.addArguments("--disable-gpu");
ChromeDriver chromeDriver = new ChromeDriver(options);
Dimension afterDimension = chromeDriver.manage().window().getSize();
width = afterDimension.getWidth();
height = afterDimension.getHeight();
// print the current window size
System.out.println("After window size is: " + width + "x" + height);
Logic Two :
Dimension size = getDriver().manage().window().getSize();
int width = size.getWidth();
int height = size.getHeight();
// print the current window size
System.out.println("Before window size is: " + width + "x" + height);
getDriver().manage().window().setSize(new Dimension(1920, 1080));
System.out.println("After window size is: " + width + "x" + height);
Logic Three: From serenity config file.
#--Browser will maximized for all the browsers
serenity.browser.maximized=true
chrome.switches =--start-maximized
serenity.browser.width=1920
serenity.browser.height=1080
The same configurations are working fine from locally(Windows Machine- Eclipse) but from Jenkins not.
I'm using the below versions: Serenity : 2.0.41 Chrome Browser : 114.0.5735.199