'Upgrade to Selenium 4 - The type or namespace name 'ChromeMobileEmulationDeviceSettings' could not be found

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 JeffC