Webdriver-Set Browser launch language
Author: Max.bai
Time: 2015/06
Webdriver-Set Browser launch language
Sometimes opening a browser requires a special language version, for example, English, Chinese.
Test found that the machine is the default startup is the system language corresponding browser, our website is measured in Chinese, and the system is in English, open browser is English, submitted some data in en-US format submitted, resulting in data error, then we need to set the browser launch language.
1. Firefox
Firefox we can solve this problem by Firefoxprofile.
Firefoxprofile FFPF = new Firefoxprofile (); FFPF. Setpreference ("Intl.accept_languages", "EN-GB");//For firefoxdriverdriver = new Firefoxdriver (FFPF);//For remote Driverdesiredcapabilities ffcaps = Desiredcapabilities.firefox (); Ffcaps.setcapability (FirefoxDriver.PROFILE, Ffpf.tostring ());d river = new Remotewebdriver (new URL (Remoteurl), ffcaps);
2. Chrome
Chrome needs to be addressed through Chromeoptions.
At the same time chromeoption can also solve the start of the browser to add the parameters of execution, such as--private.
Chromeoptions op = new Chromeoptions () op.addarguments ("--LANG=ZH-CN");//For chromedriverdriver = new Chromedriver (OP) ;//For remote driverdesiredcapabilities chromecaps = Desiredcapabilities.chrome (); Chromecaps.setcapability (" Chromeoptions ", op);d river = new Remotewebdriver (new URL (Remoteurl), chromecaps);
3. IE
IE is simple, no code to solve, directly manually set the language of IE can be, automated execution is the language you set, of course, you can also modify the registry to automate the problem, which registry to check it yourself
Webdriver-Set Browser launch language