Created
November 11, 2019 11:43
-
-
Save eviltester/02a655be5b22b73fce2f9316e1eab6d4 to your computer and use it in GitHub Desktop.
deprecated example using a firefox plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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