2016-02-12 35 views

回答

0

您可以嘗試使用firefoxprofile setPreference方法

FirefoxProfile profile = new FirefoxProfile(); 
DesiredCapabilities dc=DesiredCapabilities.firefox(); 
// this sets general.autoScroll to false and you can get all the keys you need from about:config to set your preferences 
profile.setPreference("general.autoScroll", false); 
dc = DesiredCapabilities.firefox(); 
dc.setCapability(FirefoxDriver.PROFILE, profile); 
Webdriver driver = new FirefoxDriver(dc); 
+0

你確定你的例子是一個nodejs的例子,而不是Java的例子? – doberkofler

2

我相信這是Node.js的等效Jyothishwar的代碼(假設firefox一直require d):

var profile = new firefox.Profile(); 
profile.setPreference('general.autoScroll', false); 

var opts = new firefox.Options().setProfile(profile); 

driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.firefox()) 
           .setFirefoxOptions(opts) 
           .build();