[英]Disable javascript with selenium WebDriver?
I have a program that tests some of our sites with javascript disabled. 我有一个程序可以在禁用了javascript的情况下测试我们的某些网站。 It worked well, until we updated from WebDriver 2.4.5 to the latest.
效果很好,直到我们从WebDriver 2.4.5更新到最新版本为止。 Now I get this error:
现在我得到这个错误:
java.lang.IllegalArgumentException: Preference javascript.enabled may not be overridden: frozen value=true, requested value=false
It looks like the argument to disable JS is no longer allowed. 似乎不再允许使用禁用JS的参数。 I can't downgrade the WebDriver because the earlier versions don't work correctly with our updated Firefox.
我无法降级WebDriver,因为较早的版本无法在我们更新的Firefox上正常运行。
What are my options for testing with JS disabled? 在禁用JS的情况下,我有哪些测试选项? I know Chrome never worked before, and now Firefox doesn't.
我知道Chrome以前从未使用过,现在Firefox无法使用。 I tried searching for "webdriver js disabled" but the results just bring back the
javascript.enabled, false
argument that no longer seems to work. 我尝试搜索“已禁用webdriver js”,但结果只是带回
javascript.enabled, false
参数,该参数似乎不再起作用。
Best I could come up with is; 我能想到的最好的是;
Create a new Firefox profile called NoJs by starting it with -P 通过使用-P启动一个名为NoJs的新Firefox配置文件
Go to about:config and disable javascript there 转到about:config并在那里禁用javascript
Use this profile in selenium 在硒中使用此配置文件
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("NoJs");
WebDriver driver = new FirefoxDriver(profile);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.