0

I have a simple test case where it asserts the Width and Height of an element.

Assert.AreEqual(Height, 170, 100);
Assert.AreEqual(Width, 636, 100);

The test case passes when it runs using VS test explorer. But when I create a project and run it using Jenkins project, the above test case fails every time.

Any solution for this?

2
  • Did you try to capture the screen shot on fail and look what is actually shown in the browser?
    – Alexey R.
    Mar 22, 2018 at 8:36
  • hmmm... Good idea.Let me try.
    – ChathuD
    Mar 22, 2018 at 14:21

2 Answers 2

1

The test might fail due to screen size difference.

Firstly, you may try resizing your browser with given numbers to make sure that Jenkins Server has the same Dimension as your local machine.

Something like;

Dimension dimension = new Dimension(450,600); 
driver.manage().window().setSize(dimension);

and then;

Assert.AreEqual(Height, 170, 100);
Assert.AreEqual(Width, 636, 100);
1
  • IMO, it is always a better practice to ensure that the Window dimensions are the same for all the tests. May 16, 2018 at 10:06
-1

When you are running it through Jenkins, it execute in the background and doesn't get a window. So, it will not have height and width.

6
  • This is not true. Jenkins just runs a command line. It can easily start the tests in UI session.
    – Alexey R.
    Mar 22, 2018 at 14:23
  • When you login to your machine, do you see the UI?
    – Mayur Shah
    Mar 22, 2018 at 14:24
  • If you have installed Jenkins as a service, it will be installed as an administrator user, so all your execution happens through that user. So, you have to login to the machine using that user's credentials to see the execution.
    – Mayur Shah
    Mar 22, 2018 at 14:26
  • Sorry Mayur, but I'm 100% confident that it's possible to have Jenkins execute a command to run the browser with a window. There's nothing magical about a service that prevents windows from spawning.
    – corsiKa
    Mar 22, 2018 at 15:54
  • Okay. I would like to see what it is when you resolved it.
    – Mayur Shah
    Mar 22, 2018 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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