Currently I am working on running Selenium scripts in Jenkins. Here, my issue is my browser window size which is 1382x754 px resolution.

But in Jenkins browser resolution was 1044x784. Due to this my script was unable to find the elements using x-path in Jenkins.

I have tried by setting the window size while initializing the driver, then window size is increased to 1048x788 px and then it is not increasing any more.

Any suggestions for any work around for this issue?

Environment : Windows 7 , Jenkins version(1.596), browser: Chrome

  • I had faced a similar issue. Scrolling was enabled on the modal window, so I scrolled down and then tried to access the element. It worked for me.
    – Sanchita
    Commented Feb 2, 2016 at 7:18
  • Thanks @Sanchita, My issue is not resolved as you suggested bcoz when I am going fetch the text of an element by using xpath locator.When the screen resolution is different to my local and jenkins browser. xpath value is getting changed so my script fails in jenkins browser.If I change the xpath according to jenkins browser then i9t will fail in my local browser.
    – QAMember
    Commented Feb 2, 2016 at 10:02
  • I am not suggesting. My scenario is like that @user246
    – QAMember
    Commented Feb 19, 2016 at 7:51
  • Apologies, comment was intended for Op, I entered it in the wrong place.
    – user246
    Commented Feb 19, 2016 at 13:17
  • Maximising the browser at the beginning might help abit also.
    – masood ghz
    Commented Apr 4, 2016 at 10:15

6 Answers 6


Me and my team encountered the same issue. In our case, the web app we were testing had a responsive view which caused our selectors to become invalid when browser window was reduced to such a small size (such as when being ran on Jenkins). Below are the steps we used to rectify the issue. Mind you, our Jenkins instance is being run on a VM with Windows installed.

  1. Create a new Jenkins node whose Launch Method is "Launch Agent via Java Web Start"

enter image description here

  1. In the jenkins node list, click on that nodes title and get its java web start launch command.

enter image description here

  1. Login to the VM, open up a terminal and run that command.

  2. Configure your jenkins jobs to only run on that node. In the jobs configure page:

enter image description here

Final Notes

  • We opted to have the javaws command to run everytime our VM was booted (via Windows Task Scheduler)
  • Notice how we didn't specify the node to run as a windows service. In our testing we found that having the node run as a windows service caused the resolution issue to persist.
  • This method forces the job to run directly on the VM, using the VM's resolution. In other words the resolution you see when you log into the VM will be the resolution your jobs run on. A side effect of this solution is that jobs will no longer run in the background. If you log into the VM with automation running, you'll be able to see it do its thing.

Windows Services Blurb

We had initially tried to run the new node as a windows service but wasn't able to find a way to fix the resolution issue. In the off chance that someone has arrived at this thread with this issue and is being forced to run their node as a service, the following may help them (it didn't for us).

  • Set the windows registry key NoInteractiveServices to 0
  • In windows services, disable Interactive Services Detection
  • In the service settings on windows, enable 'Allow Desktop Interaction'

I think you should commit code using Jenkins browser resolution (1044x784) to resolve issue on Jenkins.

On your local machine, you can change it to match with local resolution (but don't commit it).


I simply defaulted selenium driver to open a browser resolution that will fit on both machines and even switched the xpath to css selector. Made it much easier for me to find the element.


During the test run set the window size.

driver.manage().window().setSize(new Dimension(1044,784));

You can also try to make it larger, on the Jenkins run it might also make the windows larger then the display viewport.


You can try something like this:

public void clickElementJS(String path, String formName){
    String xpathValue = cfg.config(path, formName);
    element = GenericExecutors.driver.findElement(By.xpath(xpathValue));
    JavascriptExecutor js = (JavascriptExecutor) driver;

I am facing the same issue. And found two different resolutions.

  1. If your requirement is to see the chrome browser then open the command prompt and execute the below command

    Java -jar jenkins.war

  2. If your goal is just to change the resolution then add the below options and you can see the configure resolution(in below example resolution is 1920,1080):-

    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");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.