Auto translate of web pages does not work with headless chrome

900 views
Skip to first unread message

sra...@gmail.com

unread,
May 20, 2020, 6:00:03 AM5/20/20
to headless-dev
Environment:
Selenium (python) + chromedriver 
Chrome version : Version 81.0.4044.138 (Official Build) (64-bit)

I am using following mechanism to cause auto-translation of web pages with Thai to English.  

prefs = {
"translate_whitelists": {"th" : "en"},
"translate" : { "enabled" : "true"}
}
driver_options.add_experimental_option("prefs", prefs)

The translation works when using headed mode and page source returned by selenium has translation content.

If switch to headless mode using --headless option, the pages are not translated.

PhistucK

unread,
May 20, 2020, 6:19:23 AM5/20/20
to sra...@gmail.com, headless-dev
I believe the translation feature is a feature implemented in //chrome, not in //content. Since headless is based on //content and not //chrome, I think it makes sense that it is not supported.
(So this is probably by design)

Even if not, you probably need a Google API key for the translation to work (which comes built in with Chrome, but not with headless, I suppose).

PhistucK


--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/d07ce184-e990-4b01-9258-8722b9ea337a%40chromium.org.

sra...@gmail.com

unread,
May 20, 2020, 8:04:32 AM5/20/20
to headless-dev, sra...@gmail.com
Actually, I needed to run headless chrome because I am running it inside docker container.
I switched to headful chrome using Xvfg inside container and the translation works.


On Wednesday, May 20, 2020 at 3:49:23 PM UTC+5:30, PhistucK wrote:
I believe the translation feature is a feature implemented in //chrome, not in //content. Since headless is based on //content and not //chrome, I think it makes sense that it is not supported.
(So this is probably by design)

Even if not, you probably need a Google API key for the translation to work (which comes built in with Chrome, but not with headless, I suppose).

PhistucK


On Wed, May 20, 2020 at 1:00 PM <sra...@gmail.com> wrote:
Environment:
Selenium (python) + chromedriver 
Chrome version : Version 81.0.4044.138 (Official Build) (64-bit)

I am using following mechanism to cause auto-translation of web pages with Thai to English.  

prefs = {
"translate_whitelists": {"th" : "en"},
"translate" : { "enabled" : "true"}
}
driver_options.add_experimental_option("prefs", prefs)

The translation works when using headed mode and page source returned by selenium has translation content.

If switch to headless mode using --headless option, the pages are not translated.

--
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headle...@chromium.org.
Message has been deleted

Jerry Lee Daniel

unread,
Mar 10, 2024, 5:42:24 PMMar 10
to headless-dev, sra...@gmail.com
Loans, Project and Digital Investment financing available up to $500m.
Have a Business Plan, Fundable Project and Redeemable Collateral.

Whatsapp: +1 (620) 698 1272

Reply all
Reply to author
Forward
0 new messages