我累了在selenium webdriver測試中添加restclient擴展。但是擴展沒有被添加到運行時實例firefox中。有人可以幫助我如何在瀏覽器中添加插件嗎?無法在firefoxprofile中爲restclient設置優先
FirefoxProfile profile = new FirefoxProfile();
// add any custom firefox configurations...
profile.setPreference("general.useragent.override", "some UA string");
profile.setPreference("javascript.options.showInConsole", true);
profile.setPreference("dom.max_script_run_time", 0);
// might have to uninstall, search for *.xpi, then reinstall, then search
// again and compare to find the location on your system
// ...you should probably copy this into your selenium resources directory!
File modifyHeadersXpi = new File("/home/nvenkat/.mozilla/firefox/djmkcg3c.default/extensions/{ad0d925d-88f8-47f1-85ea-8463569e756e}.xpi");
if (modifyHeadersXpi.exists()) {
profile.addExtension(modifyHeadersXpi);
profile.setPreference("modifyheaders.config.active", true);
profile.setPreference("modifyheaders.config.openNewTab", true);
profile.setPreference("extensions.sce.bypass_domain_mismatch", true);
profile.setPreference("webdriver_assume_untrusted_issuer", false);
profile.setEnableNativeEvents(true);
profile.setPreference("modifyheaders.config.migrated", true);
profile.setPreference("modifyheaders.autocomplete.name.defaults",
"[\"Accept\",\"Cache-Control\",\"Cookie\",\"Content-Length\",\"Content-Type\",\"Date\",\"Host\",\"Pragma\",\"Referer\",\"User-Agent\",\"Via\",\"X-Requested-With\",\"X-Forwarded-For\",\"X-Do-Not-Track\"]");
profile.setPreference("modifyheaders.headers.count", 1);
profile.setPreference("modifyheaders.headers.action0", "Add");
profile.setPreference("modifyheaders.headers.name0", "sox");
profile.setPreference("modifyheaders.headers.value0", "305471");
profile.setPreference("modifyheaders.headers.enabled0", true);
profile.setPreference("modifyheaders.config.active", true);
profile.setPreference("modifyheaders.config.alwaysOn", true);
}
Thread.sleep(3000);
WebDriver driver = new FirefoxDriver(profile);
你解決這個問題? – metar