Java Code Examples for org.openqa.selenium.firefox.FirefoxProfile#addExtension()
The following examples show how to use
org.openqa.selenium.firefox.FirefoxProfile#addExtension() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FirefoxCustomProfile.java From Selenium-WebDriver-3-Practical-Guide-Second-Edition with MIT License | 7 votes |
public static void main(String... args) throws IOException { System.setProperty("webdriver.gecko.driver", "./src/test/resources/drivers/geckodriver 2"); FirefoxProfile profile = new FirefoxProfile(); profile.addExtension( new File("./src/test/resources/extensions/xpath_finder.xpi")); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setProfile(profile); FirefoxDriver driver = new FirefoxDriver(firefoxOptions); try { driver.get("http://www.google.com"); } finally { driver.quit(); } }
Example 2
Source File: FirefoxDriverConfig.java From jmeter-plugins-webdriver with Apache License 2.0 | 5 votes |
private void addExtensions(FirefoxProfile profile) { JMeterProperty property = getProperty(EXTENSIONS_TO_LOAD); if (property instanceof NullProperty) { return; } CollectionProperty rows = (CollectionProperty) property; for (int i = 0; i < rows.size(); i++) { ArrayList row = (ArrayList) rows.get(i).getObjectValue(); String filename = ((JMeterProperty) row.get(0)).getStringValue(); profile.addExtension(new File(filename)); } }
Example 3
Source File: FirefoxDriverHandler.java From selenium-jupiter with Apache License 2.0 | 4 votes |
@Override public MutableCapabilities getOptions(Parameter parameter, Optional<Object> testInstance) throws IOException, IllegalAccessException { FirefoxOptions firefoxOptions = new FirefoxOptions(); if (parameter != null) { // @Arguments Arguments arguments = parameter.getAnnotation(Arguments.class); if (arguments != null) { stream(arguments.value()).forEach(firefoxOptions::addArguments); } // @Extensions Extensions extensions = parameter.getAnnotation(Extensions.class); if (extensions != null) { for (String extension : extensions.value()) { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.addExtension(getExtension(extension)); firefoxOptions.setProfile(firefoxProfile); } } // @Binary Binary binary = parameter.getAnnotation(Binary.class); if (binary != null) { firefoxOptions.setBinary(binary.value()); } // @Preferences managePreferences(parameter, firefoxOptions); // @Options FirefoxOptions optionsFromAnnotatedField = annotationsReader .getFromAnnotatedField(testInstance, Options.class, FirefoxOptions.class); if (optionsFromAnnotatedField != null) { firefoxOptions = optionsFromAnnotatedField .merge(firefoxOptions); } } return firefoxOptions; }
Example 4
Source File: ProfileFactory.java From Asqatasun with GNU Affero General Public License v3.0 | 4 votes |
/** * Add entension * @param firefoxProfile */ private void setUpExtensions(FirefoxProfile firefoxProfile) { for (String extensionPath : extensionPathList) { try { firefoxProfile.addExtension(new File(extensionPath)); } catch (IOException ex) { Logger.getLogger(this.getClass()).error(ex); } } //---------------------------------------------------------------------- // Firebug options //---------------------------------------------------------------------- firefoxProfile.setPreference("extensions.firebug.allPagesActivation", "on"); firefoxProfile.setPreference("extensions.firebug.defaultPanelName", "net"); firefoxProfile.setPreference("extensions.firebug.net.enableSites", true); firefoxProfile.setPreference("extensions.firebug.script.enableSites", true); firefoxProfile.setPreference("extensions.firebug.onByDefault",true); firefoxProfile.setPreference("extensions.firebug.currentVersion", firebugVersion); //---------------------------------------------------------------------- //---------------------------------------------------------------------- // NetExport options //---------------------------------------------------------------------- // Auto export feature is enabled by default. firefoxProfile.setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true); // Auto export feature stores results into a local file firefoxProfile.setPreference("extensions.firebug.netexport.autoExportToFile", true); // Auto export feature sends results to the server (default is false) firefoxProfile.setPreference("extensions.firebug.netexport.autoExportToServer", false); // Show preview of exported data by default. firefoxProfile.setPreference("extensions.firebug.netexport.showPreview", false); // Displaye confirmation before uploading collecetd data to the server yes/no. firefoxProfile.setPreference("extensions.firebug.netexport.sendToConfirmation", false); // Number of milliseconds to wait after the last page request to declare the page loaded. // We don't wast time // firefoxProfile.setPreference("extensions.firebug.netexport.pageLoadedTimeout", pageLoadedTimeout); // Number of milliseconds to wait after the page is exported even if not loaded yet. // Set to zero to switch off this feature. // firefoxProfile.setPreference("extensions.firebug.netexport.timeout", timeout); // firefoxProfile.setPreference("extensions.firebug.netexport.Automation", true); // Default log directory for auto-exported HAR files. firefoxProfile.setPreference("extensions.firebug.netexport.defaultLogDir", createRandomNetExportPath(firefoxProfile)); }
Example 5
Source File: XpiDriverService.java From selenium with Apache License 2.0 | 4 votes |
private void addWebDriverExtension(FirefoxProfile profile) { if (profile.containsWebDriverExtension()) { return; } profile.addExtension("webdriver", loadCustomExtension().orElse(loadDefaultExtension())); }
Example 6
Source File: DefaultSessionFactory.java From JTAF-ExtWebDriver with Apache License 2.0 | 3 votes |
/** * * @param ffp * the firefox profile specified * @param extensions * extensions desired to be added * @throws IOException */ private static void addExtensionsToFirefoxProfile(FirefoxProfile ffp, List<String> extensions) throws IOException { for (String s : extensions) { ffp.addExtension(new File(s)); } }