I know how to change languages in selenium. You will say:
options = EdgeOptions()
options.use_chromium = True
options.add_experimental_option('excludeSwitches', ['enable-logging'])
prefs = {
"translate_whitelists": {'fr':'en'},
"translate":{"enabled":"true"}}
options.add_experimental_option("prefs", prefs)
driver = Edge(executable_path=PATH, options=options)
This works fine for all types of language but when i try to change from english to another language it doesnt work. For example:
prefs = {
"translate_whitelists": {'en':'es'},
"translate":{"enabled":"true"}}
options.add_experimental_option("prefs", prefs)
But if i say "translate_whitelists": {'es':'fr'},
It works. Basically you can convert to any output language but if the input language is english it doesnt work. Please help and explain
You can solve the problem by add_argument()
. I tested it with the code you provided and it worked very well.
This is a simple example:
from msedge.selenium_tools import Edge, EdgeOptions
options = EdgeOptions()
options.use_chromium = True
options.add_argument("--lang=fr");
options.add_experimental_option('excludeSwitches', ['enable-logging'])
prefs = {
"translate_whitelists": {'en':'fr'},
"translate":{"enabled":"true"}}
options.add_experimental_option("prefs", prefs)
driver = Edge(executable_path=r"C:\Users\Administrator\Desktop\msedgedriver.exe", options=options)
driver.get("https://learn.microsoft.com/en-us/deployedge/configure-microsoft-edge")
Note: Modify the EdgeDriver path according to your situation