如何在Ferrum中使用现有的Chromium配置文件?
我已经设置好了Chromium的配置文件,并希望将其用于Ruby Ferrum库。我把完整的配置目录复制到了 /tmp,并传入了浏览器切换参数,但配置文件中的扩展似乎不起作用。当前Ferrum使用以下命令启动浏览器:
/usr/local/bin/chrome \
--headless \
--hide-scrollbars \
--mute-audio \
--enable-automation \
--disable-web-security \
--disable-session-crashed-bubble \
--disable-breakpad \
--disable-sync \
--no-first-run \
--use-mock-keychain \
--keep-alive-for-test \
--disable-popup-blocking \
--disable-component-extensions-with-background-pages \
--disable-hang-monitor \
--disable-features=site-per-process,IsolateOrigins,TranslateUI \
--disable-translate \
--disable-background-networking \
--enable-features=NetworkService,NetworkServiceInProcess \
--disable-background-timer-throttling \
--disable-backgrounding-occluded-windows \
--disable-client-side-phishing-detection \
--disable-default-apps \
--disable-dev-shm-usage \
--disable-ipc-flooding-protection \
--disable-prompt-on-repost \
--disable-renderer-backgrounding \
--disable-site-isolation-trials \
--force-color-profile=srgb \
--metrics-recording-only \
--safebrowsing-disable-auto-update \
--password-store=basic \
--no-startup-window \
--remote-allow-origins=* \
--disable-blink-features=AutomationControlled \
--remote-debugging-port=0 \
--remote-debugging-address=127.0.0.1 \
--window-size=1366,768 \
--user-data-dir=/tmp/chromium \
--profile-directory=Default
解决方案
我不得不禁用无痕模式,并仅传入用户数据目录的路径,如下所示:
OPTS = {
incognito: false,
browser_options: {
'user-data-dir' => '/tmp/chromium'
}
}
Ferrum::Browser.new(OPTS)
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。