Selenium和Firefox配置文件设置
我需要您的帮助来使用Firebug设置我的Firefox配置文件。我想要的是当我通过Selenium WebDriver启动它时,Firebug插件将被加载Firefox实例。这里是我的代码示例:Selenium和Firefox配置文件设置
final File file = new File("C:\\Program Files (x86)\\Gecko\\bin\\geckodriver.exe");
System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("?");
所以...我怎么可以设置setPreference
值,使萤火虫与Firefox的加载一起当硒的webdriver启动浏览器?
你要添加扩展,而不是设置的偏好:
final String firebugPath = "C:\\FF_Profile\\firebug.xpi";
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(firebugPath));
WebDriver driver = new FirefoxDriver(profile);
你可以找到下面这说明Firebug的路径:
Kotoj!很好的信息。感谢您抽出我的时间询问。很好的帮助! –
我的荣幸,如果我的答案帮助,请接受它;) – kotoj
kotoj ...我试过,但它似乎不工作....没有错误信息..所以我不知道为什么它不工作?无论如何感谢kotoj! –
Kotoj
这里是代码:
//告诉黄瓜在geckodriver位于环境
final File file = new File("C:\\Program Files (x86)\\Gecko\\bin\\geckodriver.exe");
// Get the absolute path to the Gecko Driver
System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());
final String firebugPath= "C:\\Users\\<My username>\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\erx927l4.default\\extension s\\[email protected]";
// Set up the Firefox browser profile
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(firebugPath));
// bring up the browser
driver = new FirefoxDriver(profile);
我想这些代码添加到评论部分,但它不会让我格式化文本,所以我必须张贴在“后你的答案“部分..对不起
Kotoj ..非常感谢跟进我的问题。这里是代码:final File file = new File(“C:\\ Program Files(x86)\\ Gecko \\ bin \\ geckodriver.exe”); System.setProperty(“webdriver.gecko.driver”,file.getAbsolutePath()); final String firebugPath =“C:\\ Users \\ jnguyen \\ AppData \\ Roaming \\ Mozilla \\ Firefox \\ Profiles \\ erx927l4.default \\ extensions \\ [email protected]”; FirefoxProfile profile = new FirefoxProfile(); profile.addExtension(new File(firebugPath)); driver = new FirefoxDriver(profile); –