-1

I have a task and it has this sentence "The automated tests should run in a browser resolution of 1024x768px"

This is how I understand it, by setting the browser size into 1024, 768 resolution.

driver.manage().window().setSize(new Dimension(1024, 768));

I don't know if this is correct or not?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
shorouk alaa
  • 9
  • 1
  • 2

2 Answers2

0

Correct, this how you set up resolution if u run your tests locally.

If u run run your tests remotely(any Cloud Testing service), then its gonna be something like this:

capabilities.setCapability("screenResolution", "1920x1080");

IPolnik
  • 619
  • 5
  • 13
0

setSize()

As per the Java Docs setSize() sets the size of the current browsing window. This command will change the outer window dimension along with the view port and is defined as:

void setSize(Dimension targetSize)

Set the size of the current window. This will change the outer window dimension, not just the view port, synonymous to window.resizeTo() in JS.

Parameters:
    targetSize - The target size.

where Dimension implies a Point which is defined as:

Dimension(int width, int height)

So by the line of code:

driver.manage().window().setSize(new Dimension(1024, 768));

You are setting the size of the Viewport with width set as 1024 and height set as 768 for the current web browsing context.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352