robottelo
robottelo copied to clipboard
Allow the UI to run using different locales
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")
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")
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")
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.
So perhaps we could create a temporary directory (mktemp I believe) to hold these profiles dynamically :)
Has there been anything done on this one?
@blrm can we get an update on this? (Moving to milestone 3 for now)