在Selenium中禁用Javascript?Noscript不';好像不行
我正在尝试使用noscript扩展禁用selenium中的javascript,正如这里建议的--> 但是,它看起来已经不起作用了, 以下是我写的:在Selenium中禁用Javascript?Noscript不';好像不行,javascript,java,firefox,selenium,firefox-addon,Javascript,Java,Firefox,Selenium,Firefox Addon,我正在尝试使用noscript扩展禁用selenium中的javascript,正如这里建议的--> 但是,它看起来已经不起作用了, 以下是我写的: FirefoxProfile profile = new FirefoxProfile(); File extPath = new File("noscript.xpi"); profile.addExtension(extPath); //profile.setPreference("javascript.enab
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的概要文件来尝试,这似乎也不起作用
代码:
我正在Firefox 43.0.1版和selenium 2.48.2版上试用
有什么办法吗?
谢谢:)
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");