How do I set the language for Ghostdriver PhantomJs with java?
I am using Ghostdriver PhantomJs with Java to take some screenshots of web pages. My problem is that PhantomJs are using the locale from the host machine, so I need to set the default language. I have found how to do this for Chrome Driver and Firefox but cannot find a solution for Ghostdriver.
Any hints?
+3
source to share
1 answer
For this question and this pull request (and of course tested):
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX + "Accept-Language", "it-IT");
WebDriver driver = new PhantomJSDriver(caps );
The constant above is at org.openqa.selenium.phantomjs.PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX
.
Don't forget to change the language it-IT
to whatever you need.
+6
source to share