使用headless gem加载配置文件



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

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

是否可以使用无头宝石?

我当前的代码,

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

只是相同的

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

最新更新