Home > Enterprise >  Chrome Options Doesn't Apply Upon Loading The Page In Selenium
Chrome Options Doesn't Apply Upon Loading The Page In Selenium

Time:07-03

I'm trying to scrape an Amazon French page using Selenium. I want this page to be translated from French to English upon loading. I have attempted to do that using following code:

myoptions = webdriver.ChromeOptions()
prefs = {
    "translate_whitelists": {"fr":"en"},
    "translate": {"enabled":"true"}
}
myoptions.add_experimental_option("prefs", prefs)
path = r'C:\chromedriver.exe'
browser = webdriver.Chrome(executable_path=path, options=myoptions)
browser.get("https://www.amazon.fr/dp/0001002791")

However, when the page loads, it still shows up in French, as you can see in the image below: enter image description here

Now, if I navigate to any other link from this webpage, the option to translate the webpage works and the icon shows in the search bar. Plus, the message of translation also pop ups as shown below: enter image description here

From here on, all of the webpages gets translated, even the initial one, as you can see: enter image description here

Why didn't it work earlier when the page loaded? How do I fix this?

CodePudding user response:

As described in this enter image description here

  • Related