如何使用Selenium ChromeDriver翻译网页语言

时间:2016-12-16 13:48:12

标签: java selenium automated-tests

当我运行脚本时,网页以土耳其语开启。我想用英语转换,尝试使用chrome选项下面的代码片段,但它将浏览器语言设置为英语而不是网页语言。请帮助

static DesiredCapabilities setChromeCapabilities()
   {
      Map<String, Object> prefs = new HashMap<String, Object>();

      prefs.put("profile.default_content_settings.popups", 1);
      prefs.put("download.default_directory", "C:\\dev\\tmpReport");

      ChromeOptions options = new ChromeOptions();
      options.setExperimentalOption("prefs", prefs);
      options.addArguments("chrome.switches","--disable-extensions");
      options.addArguments("--start-maximized");
      options.addArguments("--lang=en");  **//tried adding this line of code** 

      DesiredCapabilities capabilities = DesiredCapabilities.chrome();
      capabilities.setCapability(ChromeOptions.CAPABILITY,options);
      return capabilities;
   } 

0 个答案:

没有答案