watir-webdriver - 使用无头宝石加载配置文件

时间:2012-03-13 16:43:24

标签: watir-webdriver headless headless-browser

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

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

是否可以使用。加载firefox配置文件 headless宝石?

我目前的代码,

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

1 个答案:

答案 0 :(得分:1)

就是一样

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

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