Selenium 3.5 Options.ToCapabilities 没有将选项应用到 RemoteWebDriver

Selenium 3.5 Options.ToCapabilities is not applying the options to RemoteWebDriver

我有几个使用 Selenium 3.3 的命令行选项,如下所示:

`DesiredCapabilities capabilities = new DesiredCapabilities();
 capabilities = DesiredCapabilities.Chrome();
 options.AddArguments("--lang=en-GB");
 options.AddArguments("--high-dpi-support=1");
 options.AddArguments("--force-device-scale-factor=0.8");
 capabilities = options.ToCapabilities() as DesiredCapabilities;
 Driver = new RemoteWebDriver(new Uri("WIN10:5566/wd/hub"), capabilities, 
 TimeSpan.FromSeconds(180));`

但是切换到 Selenium 3.5.2 后,即使在使用新的 ToCapabilities() 时也不再应用这些选项,如下所示:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--lang=en-GB");
options.AddArguments("--high-dpi-support=1");
options.AddArguments("--force-device-scale-factor=0.5");
Driver = new RemoteWebDriver(new Uri("http://WIN10:5566/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(180));

我还需要什么吗?

尝试替换

capabilities = options.ToCapabilities() as DesiredCapabilities; 

以下内容:

capability.setCapability(ChromeOptions.CAPABILITY, options);

那么你只需要在RemoteWebDriver中指定"capability":

RemoteWebDriver(new URL("your url"), capability);

谢谢 smit,那也行。问题是 chrome 驱动程序需要更新(这里是尴尬的表情符号!)