-
|
I know I may just be loosing my time here, because I'm not suppose to see what's going on in headless mode, but I sometimes connect via VNC to the Xvfb session to debug things and this translate pop-up annoys me. First, I know about I've tried to use these flags in SB, as well as others, e.g. lang, but it doesn't help. My code is: import asyncio
import mycdp
from seleniumbase import cdp_driver
from seleniumbase.undetected.cdp_driver.browser import Browser
from seleniumbase.undetected.cdp_driver.tab import Tab
async def main():
browser: Browser = await cdp_driver.start_async(ad_block=True,
lang='it-IT',
user_data_dir='/tmp/uc_zlnpod6m',
browser_args=[
'--lang=it-IT',
'--disable-translate',
'--disable-features=Translate'])
await browser.main_tab.send(mycdp.emulation.set_locale_override('it_IT'))
tab: Tab = await browser.get('https://www.corriere.it')
await asyncio.sleep(50)
browser.stop()
if __name__ == '__main__':
loop = asyncio.new_event_loop()
loop.run_until_complete(main())Nothing works, I still get the pop-up. Then, I've tried to modify the user_data_fir Preferences file, with the values below, but the preferences seems to be overwritten: {
"intl": {"accept_languages": "it-IT,it"},
"translate": {"enabled": false},
"translate_blocked_languages": ["it"]
}Actually, the only thing that works is this comment which says to create {
"TranslateEnabled": false
}I could leave it here and use this solution, but it leaves outside of my code, so I don't really like it. Any other idea? It's strange that this only impacts headless mode. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Looks like Google removed the options that prevent the translate pop-up from appearing in Chrome, but fortunately that doesn't seem to interfere with automation that comes after that. Additionally, PyAutoGUI can remove that pop-up by pressing "Esc" from a sync CDP Mode format:
Eg: from seleniumbase import sb_cdp
url = "https://www.corriere.it"
sb = sb_cdp.Chrome(url)
sb.wait_for_element("#privacy-cp-wall-accept")
sb.sleep(3)
sb.gui_press_key("Esc")
sb.sleep(3)
sb.driver.stop()Sometimes that pop-up appears a few seconds after the page has loaded. You may need to adjust timing as needed. |
Beta Was this translation helpful? Give feedback.
Looks like Google removed the options that prevent the translate pop-up from appearing in Chrome, but fortunately that doesn't seem to interfere with automation that comes after that.
Additionally, PyAutoGUI can remove that pop-up by pressing "Esc" from a sync CDP Mode format:
sb.gui_press_key("Esc")Eg:
Sometimes that pop-up appears a few seconds after the page has loaded. You may need to adjust timing as needed.