我正在尝试使用noscript扩展程序禁用selenium中的javascript,如此处所示 - > How to disable Javascript when using Selenium by JAVA?
但是,看起来它已经不再适用了, 这是我写的:
FirefoxProfile profile = new FirefoxProfile();
File extPath = new File("noscript.xpi");
profile.addExtension(extPath);
//profile.setPreference("javascript.enabled", false);
WebDriver driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://enable-javascript.com");
甚至尝试通过加载已禁用javascript的配置文件来尝试它,这似乎也不起作用。
代码:
File profileDirectory = new File("Profiles/4hsi6txm.testing");
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
DesiredCapabilities cap = DesiredCapabilities.firefox();
//
cap.setCapability(FirefoxDriver.PROFILE, profile);
WebDriver driver = new FirefoxDriver(cap);
driver.get("http://enable-javascript.com");
我正在Firefox version-43.0.1
和selenium version-2.48.2
对此有何修复? 谢谢:))