diff --git a/docs_source_files/content/support_packages/chrome_devtools.en.md b/docs_source_files/content/support_packages/chrome_devtools.en.md index b05551d8a74e..d45bca9cd49c 100644 --- a/docs_source_files/content/support_packages/chrome_devtools.en.md +++ b/docs_source_files/content/support_packages/chrome_devtools.en.md @@ -343,7 +343,54 @@ public void deviceSimulationTest() { # Please raise a PR to add code sample {{< / code-panel >}} {{< code-panel language="csharp" >}} -# Please raise a PR to add code sample + +using OpenQA.Selenium; +using OpenQA.Selenium.Chrome; +using OpenQA.Selenium.DevTools; +using System.Threading.Tasks; +using OpenQA.Selenium.DevTools.V91.Emulation; +using WebDriverManager; +using WebDriverManager.DriverConfigs.Impl; +using DevToolsSessionDomains = OpenQA.Selenium.DevTools.V91.DevToolsSessionDomains; + +namespace Selenium4Sample +{ + public class ExampleDevice + { + + protected IDevToolsSession session; + protected IWebDriver driver; + protected DevToolsSessionDomains devToolsSession; + + + public async Task DeviceModeTest() + { + new DriverManager().SetUpDriver(new ChromeConfig()); + ChromeOptions chromeOptions = new ChromeOptions(); + //Set ChromeDriver + driver = new ChromeDriver(); + //Get DevTools + IDevTools devTools = driver as IDevTools; + //DevTools Session + session = devTools.GetDevToolsSession(); + + var deviceModeSetting = new SetDeviceMetricsOverrideCommandSettings(); + deviceModeSetting.Width = 600; + deviceModeSetting.Height = 1000; + deviceModeSetting.Mobile = true; + deviceModeSetting.DeviceScaleFactor = 50; + + + await session + .GetVersionSpecificDomains() + .Emulation + .SetDeviceMetricsOverride(deviceModeSetting); + + driver.Url = "https://www.netmarble.net/"; + } + + } +} {{< / code-panel >}} {{< code-panel language="ruby" >}} # Please raise a PR to add code sample