Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To configure Chrome to UK BST in Azure Pipeline using C# and Selenium, you can use the following code:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--no-sandbox");
options.AddArguments("--disable-dev-shm-usage");
options.AddArguments("--disable-gpu");
options.AddArguments("--headless");
options.AddArguments("--disable-setuid-sandbox");
options.AddArguments("--dns-prefetch-disable");
options.AddArguments("--lang=en-gb");
options.AddArguments("--disable-extensions");
options.AddArguments("--disable-popup-blocking");
options.AddArguments("--window-size=1920x1080");
options.AddArguments($"--user-data-dir={chromeUserData}");

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("GMT Standard Time");
options.AddArguments($"--disable-time-zone-support=false");
options.AddArguments($"--disable-infobars");
options.AddArguments($"--start-maximized");
options.AddArguments($"--disable-features=LanguageEnforcement");
options.AddArguments($"--disable-features=NetworkService");
options.AddArguments($"--disable-features=VizDisplayCompositor");
options.AddArguments($"--disable-features=RendererCodeIntegrity");
options.AddArguments($"--timezone-id={tzi.Id}");
IWebDriver driver = new ChromeDriver(ChromeDriverService.CreateDefaultService(), options);

This code sets various Chrome options, including setting the language to UK English (--lang=en-gb) and setting the timezone to GMT Standard Time (--timezone-id={tzi.Id}). It then creates a new ChromeDriver with these options.

Note that you may need to change the timezone ID ("GMT Standard Time") to a different ID depending on your specific needs. You can find a list of valid timezone IDs in the Microsoft documentation.