robottelo icon indicating copy to clipboard operation
robottelo copied to clipboard

Allow the UI to run using different locales

Open omaciel opened this issue 11 years ago • 6 comments

We should be able to run the UI automation using different locales.

NOTE: Firefox allows you to create a profile dynamically which would allow us to create a localized profile. Need to test other browsers.

from selenium import webdriver

profile = webdriver.firefox.firefox_profile.FirefoxProfile()
profile.set_preference("intl.accept_languages", "fr")

browser = webdriver.Firefox(profile)

browser.get("http://google.com")

omaciel avatar Nov 11 '13 15:11 omaciel

This should work for all browsers but I cannot get it to work:

from selenium import webdriver

capabilities =  webdriver.chrome.options.DesiredCapabilities.CHROME
capabilities["intl.accept_languages"] = "fr"

driver = webdriver.Chrome(desired_capabilities=capabilities)
driver.get("http://google.com")

omaciel avatar Nov 11 '13 18:11 omaciel

This also does not seem to change the locale:

from selenium import webdriver

options = webdriver.chrome.options.Options()
options.add_argument('--lang=fr')

driver = webdriver.Chrome(chrome_options=options)
driver.get("http://google.com")

omaciel avatar Nov 11 '13 19:11 omaciel

This is a workaround for chrome (and other possibly other browsers). It would require that we create a dummy profile for each language we want to use, like this:

from selenium import webdriver

options = webdriver.ChromeOptions()
# chrome will create a profile in the user-data-dir directory if one doesn't already exist
options.add_argument("user-data-dir=/home/blair/chromeprofiles/es") 
browser = webdriver.Chrome(chrome_options=options)
# once the browser loads, change the preferred language in settings to "es"
# confirm that the correct language is used on a page.
browser.get("http://google.com")
browser.quit()

Then, to use that language in the future, you can just set the user-data-dir path to that profile and it will launch a browser with the correct language.

blrm avatar Nov 21 '13 20:11 blrm

So perhaps we could create a temporary directory (mktemp I believe) to hold these profiles dynamically :)

omaciel avatar Nov 21 '13 21:11 omaciel

Has there been anything done on this one?

cswiii avatar Dec 16 '13 20:12 cswiii

@blrm can we get an update on this? (Moving to milestone 3 for now)

sthirugn avatar Feb 21 '14 18:02 sthirugn