2

I'm upgrading a C# program that was using Selenium 3. After updating Selenium to version 4, I get this error

The type or namespace name 'ChromeMobileEmulationDeviceSettings' could not be found

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
...
var chromeMobileEmulationDeviceSettings = new ChromeMobileEmulationDeviceSettings(userAgentString)
{
    Width = width,
    Height = height
};

var chromeOptions = new ChromeOptions();
chromeOptions.EnableMobileEmulation(chromeMobileEmulationDeviceSettings);
chromeOptions.AddArguments("headless");

_webDriver = new ChromeDriver(chromeOptions);

_webDriver.Manage().Window.Maximize();

I don't see any mention in the docs, etc., of that class being deprecated. I want to force the 'browser' to have a very specific height/width when it is opened. I've seen related answers here How do I set browser width and height in Selenium WebDriver? But I have a similar concern about setting the size before instantiating the driver, and also those answers are 'old', so what is best practice for doing this in Selenium 4?

DennisR
  • 127
  • 2
  • 7

1 Answers1

1

You can replace ChromeMobileEmulationDeviceSettings with ChromiumMobileEmulationDeviceSettings. The name just updated.

JeffC
  • 22,180
  • 5
  • 32
  • 55