I am trying to fit all the objects in the window (Chrome browser). Manually when I am doing it(the dimensions that I am using is 1024X786 using toggle bar, but when I am automating it using the same dimension, it's not showing the same as it was manually.
The following is the code:
driver = new ChromeDriver();
Map<String, Object> deviceMetrics = new HashMap<String, Object>();
deviceMetrics.put("width", 768);
deviceMetrics.put("height", 1024);
Map<String, Object> mobileEmulation = new HashMap<String, Object>();
mobileEmulation.put("deviceMetrics", deviceMetrics);
mobileEmulation.put("userAgent", "Mobile S");
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
System.out.println("Driver is now ChromeDriver");
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
The footer is getting lost in this. What I am getting is:

What I am suppose to get is this:

Another code I used is:
driver.manage().window().setSize(new Dimension(1024, 786));
Can anyone please help? Thanks
Setting the size of the window wont work if you want to fit contents of a web page in window without scroll If it's a large page.
What you will have to do is adjust the zoom level to fit all contents in window.
You can do this as shown below:
Make sure to reset the zoom level afterwards as shown below:
What basically happens here is the same as what happens when you press Control and - in your keyboard while focusing on your browser.
Try it out, if this serves your purpose.