如何使用nodejs selenium webdriver设置elementScrollBehavior功能

时间:2016-02-12 16:50:51

标签: node.js selenium selenium-webdriver

我按如下方式创建驱动程序:

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

如何设置elementScrollBehavior

2 个答案:

答案 0 :(得分:2)

我相信这是Jyothishwar代码的Node.js等价物(假设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();

答案 1 :(得分:0)

You can try using the firefoxprofile setPreference Method

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);