0
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

Borra Suneel
  • 196
  • 1
  • 2
  • 6
  • For the Jenkins script configuration I think you should also be explcitly setting to run headlessly. `chrome.switches=--window-size=1920,1080;--headless` – BernardV Jun 27 '23 at 06:56
  • I have tried this also at Jenkins goals level verify -DexeEnvironment="$ExecutionEnvironment" -DsiteId="$SiteId" -DesatUsername="$eSatUserName" -DesatLoginPwd="$eSatUserPwd" -Dreport.customfields.environment="$ExecutionEnvironment" -Dbatches="$Module" -Dwebdriver.driver="$Browser" -Dfailsafe.rerunFailingTestsCount=0 -Dchrome.switches="--disable-gpu" -Dchrome.switches=--headless -Dchrome.switches=--window-size=1920,1080 – Borra Suneel Jun 27 '23 at 10:52

0 Answers0