Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
deprecated example using a firefox plugin
@Test
public void firefoxUseExtensions() throws IOException {
// **************************************************************************
// profile is good for setting preferences and fiddling with browser settings
// **************************************************************************
// Download the extension to a local folder
String s = File.separator;
String extensionPath = System.getProperty("user.dir") +
String.format("%ssrc%stest%sresources%s%s",s,s,s,s,"firebug-1.10.5-fx.xpi");
System.out.println(extensionPath);
FirefoxProfile profile = new FirefoxProfile();
// stop firebug showing the first run screen by setting the last version
// to the current one
profile.setPreference("extensions.firebug.currentVersion", "1.10.5");
// add the extension to firefox
profile.addExtension(new File(extensionPath));
// prior to 3.12.0 we could set the profile
//WebDriver firefox = new FirefoxDriver(profile);
// in 3.12.0 we use the option
FirefoxOptions options = new FirefoxOptions().setProfile(profile);
WebDriver firefox = new FirefoxDriver(options);
firefox.get("https://testpages.herokuapp.com/selenium/basic_html_form.html");
assertThat(firefox.getTitle(), is("HTML Form Elements"));
firefox.quit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment