SatelliteQE / robottelo

Robottelo is a test suite that exercises The Foreman.
GNU General Public License v3.0
61 stars 114 forks source link

Allow the UI to run using different locales #21

Open omaciel opened 10 years ago

omaciel commented 10 years ago

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 commented 10 years ago

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 commented 10 years ago

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")
blrm commented 10 years ago

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.

omaciel commented 10 years ago

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

cswiii commented 10 years ago

Has there been anything done on this one?

sthirugn commented 10 years ago

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