0

I have a requirement to test a webpage using chrome browser on various devices like pc, iphone and ipad to verify the orientation and display of various UI elements.

I'm able to view the display and orientation using the developer tools in chrome on my pc for various mobile devices.

However I wanted to know if I can test this by launching the chrome browser using selenium and c# to resize the window as per the resolution of ipad in chrome developer tools.

Would this be a reliable way to test?

 driver.Manage().Window.Size = new System.Drawing.Size(320, 568);
KunduK
  • 32,888
  • 5
  • 17
  • 41
Py_learner
  • 53
  • 8

1 Answers1

0

To resize the Chrome Browser window you can use either of the following options:

  • Using IWindow Interface:

    driver.Manage().Window.Size = new Size(1024, 768);
    
  • Using ChromeOptions and AddArgument() :

    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.AddArgument("--window-size=1024,768");
    IWebDriver driver = new ChromeDriver(chromeOptions)
    
  • Using ExecuteScript():

    ((IJavaScriptExecutor)driver).ExecuteScript("window.resizeTo(1024, 768);");
    

You can find a Java based relevant solution in Fitting objects in window screen using Selenium Java

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