0

目标是以与常规浏览器对象相同的方式设置配置文件,

$browser = Watir::Browser.new b, :profile => profile

是否可以使用 无头gem 加载 Firefox 配置文件?

我当前的代码,

profile = Selenium::WebDriver::Firefox::Profile.new
profile['browser.download.folderList'] = 2
profile['browser.download.dir'] = "#{Dir.pwd}"
profile['browser.helperApps.neverAsk.saveToDisk'] = "application/pdf,application/x-tar-gz, application/x-gzip, application/x-compressed"

if $global_cfg['headless'] == 'on'
    headless = Headless.new
    headless.start
    $browser = Watir::Browser.start url.to_s
else
    $browser = Watir::Browser.new b, :profile => profile
    $browser.goto url.to_s
end
4

1 回答 1

1

一样

if $global_cfg['headless'] == 'on'
    headless = Headless.new
    headless.start
end

$browser = Watir::Browser.new b, :profile => profile
$browser.goto url.to_s
于 2012-03-15T09:19:45.330 回答