List of usage examples for org.openqa.selenium.firefox FirefoxProfile FirefoxProfile
public FirefoxProfile(File profileDir)
From source file:edu.uga.cs.clickminer.test.BrowserEngineTest.java
License:Open Source License
/** * <p>browserEngineTest_17.</p> * * @throws java.io.IOException if any.//from w w w . j a va2 s .c o m * @throws java.lang.InterruptedException if any. * @throws edu.uga.cs.clickminer.exception.ProxyErrorException if any. */ public static void browserEngineTest_17() throws IOException, InterruptedException, ProxyErrorException { FirefoxProfile profile = new FirefoxProfile( TestUtils.getWebdriverProfile("/home/cjneasbi/.mozilla/firefox", "webdriver")); WebDriver wdriver = new FirefoxDriver( new FirefoxBinary(new File("/home/cjneasbi/Desktop/old_firefox/firefox-17.0/firefox-bin")), profile, TestUtils.createProxyConfig()); ProxyClient pc = new ProxyClient("127.0.0.1", 8888); BrowserEngine bengine = new BrowserEngine(pc, wdriver, true, true); wdriver.get("file:///home/cjneasbi/workspace/clickminer-browser/resource/test/js_test.html"); wdriver.switchTo().activeElement(); Thread.sleep(5000); List<WebElement> elements = bengine.findJSClickableElements(); for (WebElement elem : elements) { System.out.println(elem.getAttribute("id")); } bengine.close(); }
From source file:edu.uga.cs.clickminer.test.BrowserEngineTest.java
License:Open Source License
/** * <p>browserEngineTest_18.</p> * * @throws java.io.IOException if any./*www.j av a 2 s. c o m*/ * @throws java.lang.InterruptedException if any. */ public static void browserEngineTest_18() throws IOException, InterruptedException { FirefoxProfile profile = new FirefoxProfile( TestUtils.getWebdriverProfile("/home/cjneasbi/.mozilla/firefox", "webdriver")); WebDriver wdriver = new FirefoxDriver( new FirefoxBinary(new File("/home/cjneasbi/Desktop/old_firefox/firefox-17.0/firefox-bin")), profile); // WebDriver wdriver = new FirefoxDriver(); wdriver.get("http://www.cs.uga.edu/~neasbitt/"); wdriver.switchTo().activeElement(); Thread.sleep(5000); WebElement elem = wdriver.findElement(By.id("profile")); Map<String, String> attrs = JSUtils.getElementAttributes(wdriver, elem); System.out.println(attrs); wdriver.close(); }
From source file:edu.uga.cs.clickminer.test.BrowserEngineTest.java
License:Open Source License
/** * <p>browserEngineTest_19.</p> * * @throws edu.uga.cs.clickminer.exception.ProxyErrorException if any. * @throws java.lang.InterruptedException if any. */// ww w .j a va 2s .co m public static void browserEngineTest_19() throws ProxyErrorException, InterruptedException { FirefoxProfile profile = new FirefoxProfile( TestUtils.getWebdriverProfile("/home/cjneasbi/.mozilla/firefox", "webdriver")); WebDriver wdriver = new FirefoxDriver( new FirefoxBinary(new File("/home/cjneasbi/Desktop/old_firefox/firefox-17.0/firefox-bin")), profile, TestUtils.createProxyConfig()); for (int i = 0; i < 10; i++) { //wdriver.get("http://choices.truste.com/get?name=admarker-full-tr.png"); wdriver.get("http://blah.blah.com"); Thread.sleep(5000); } wdriver.quit(); }
From source file:edu.uga.cs.clickminer.test.ProxyClientTest.java
License:Open Source License
/** * <p>proxyClientTest_7.</p> * * @throws java.lang.Exception if any.//from w w w . j a v a2s .co m */ public static void proxyClientTest_7() throws Exception { FirefoxProfile profile = new FirefoxProfile( TestUtils.getWebdriverProfile("/home/cjneasbi/.mozilla/firefox", "webdriver")); WebDriver wdriver = new FirefoxDriver( new FirefoxBinary(new File("/home/cjneasbi/Desktop/old_firefox/firefox-14.0.1/firefox-bin")), profile, TestUtils.createProxyConfig()); ProxyClient pc = new ProxyClient("127.0.0.1", 8888); pc.setModeNoContent("http://www.newegg.com"); if (pc.getMode() == ProxyMode.NOCONTENT) { System.out.println("Pass"); } else { System.out.println("Fail"); } wdriver.get("http://www.yahoo.com"); Thread.sleep(2000); if (pc.getMode() == ProxyMode.NOCONTENT) { System.out.println("Pass"); } else { System.out.println("Fail"); } wdriver.get("http://www.newegg.com"); Thread.sleep(2000); if (pc.getMode() == ProxyMode.CONTENT) { System.out.println("Pass"); } else { System.out.println("Fail"); } wdriver.close(); }
From source file:edu.umd.cs.guitar.ripper.WebDriverTest.java
License:Open Source License
@Test public void testDriverBehaviors() { System.out.println("testDriverBehaviors"); FirefoxProfile profile = new FirefoxProfile(new File("/home/baonn/.mozilla/firefox")); profile.setPreference("network.http.phishy-userpass-length", 255); FirefoxDriver driver = new FirefoxDriver(profile); driver.get("https://www.google.com/analytics/web/"); }
From source file:gov.nih.nci.firebird.commons.selenium2.test.WebDriverModule.java
License:Open Source License
@Provides @Singleton/*from w w w.j av a2 s. c om*/ @Named("selenium.firefox.driver") public WebDriver provideFirefoxDriver(@Named("selenium.firefox.profile.location") String profileLocation, @Named("selenium.firefox.binary.location") String binaryLocation) { FirefoxProfile profile = null; FirefoxBinary binary = null; try { File profileDir = new File(profileLocation); profile = new FirefoxProfile(profileDir); } catch (UnableToCreateProfileException e) { } File binaryDir = new File(binaryLocation); if (binaryDir.exists()) { binary = new FirefoxBinary(binaryDir); } WebDriver driver = new FirefoxDriver(binary, profile); closeDriverOnShutdown(driver); return driver; }
From source file:net.continuumsecurity.web.drivers.DriverFactory.java
License:Open Source License
public WebDriver createFirefoxDriver(DesiredCapabilities capabilities) { if (capabilities != null) { return new FirefoxDriver(capabilities); }/*from www . j ava 2 s . c o m*/ ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile myProfile = allProfiles.getProfile("WebDriver"); if (myProfile == null) { File ffDir = new File(System.getProperty("user.dir") + File.separator + "ffProfile"); if (!ffDir.exists()) { ffDir.mkdir(); } myProfile = new FirefoxProfile(ffDir); } myProfile.setAcceptUntrustedCertificates(true); myProfile.setAssumeUntrustedCertificateIssuer(true); myProfile.setPreference("webdriver.load.strategy", "unstable"); if (capabilities == null) { capabilities = new DesiredCapabilities(); } capabilities.setCapability(FirefoxDriver.PROFILE, myProfile); return new FirefoxDriver(capabilities); }
From source file:org.apache.activemq.transport.ws.WSTransportTest.java
License:Apache License
protected WebDriver createFireFoxWebDriver() throws Exception { File profile = new File(profileDir, "firefox"); profile.mkdirs();//from w w w . ja v a2 s .c o m return new FirefoxDriver(new FirefoxProfile(profile)); }
From source file:org.asqatasun.sebuilder.tools.ProfileFactory.java
License:Open Source License
/** * /*from w ww . ja v a 2s. c om*/ * @return * a set-up Firefox profile */ private FirefoxProfile getProfile(boolean loadImage) { if (StringUtils.isNotBlank(pathToPreSetProfile)) { File presetProfileDir = new File(pathToPreSetProfile); if (presetProfileDir.exists() && presetProfileDir.canRead() && presetProfileDir.canExecute() && presetProfileDir.canWrite()) { Logger.getLogger(this.getClass()) .debug("Start firefox profile with path " + presetProfileDir.getAbsolutePath()); return new FirefoxProfile(presetProfileDir); } else { Logger.getLogger(this.getClass()).debug("The profile with path " + presetProfileDir.getAbsolutePath() + " doesn't exist or don't have permissions"); } } Logger.getLogger(this.getClass()).debug("Start firefox with fresh new profile"); FirefoxProfile firefoxProfile = new FirefoxProfile(); setUpPreferences(firefoxProfile, loadImage); // setUpExtensions(firefoxProfile); setUpProxy(firefoxProfile); return firefoxProfile; }
From source file:org.finra.jtaf.ewd.impl.DefaultSessionFactory.java
License:Apache License
@Override public WebDriver createInnerDriver(Map<String, String> options, DesiredCapabilities capabilities) throws Exception { ClientProperties properties = new ClientProperties(options.get("client")); WebDriver wd = null;/*w w w .ja v a 2 s.c o m*/ DesiredCapabilities desiredCapabilities = new DesiredCapabilities(capabilities); String browser = properties.getBrowser(); if (properties.isUseGrid()) { RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL(properties.getGridUrl()), capabilities); remoteWebDriver.setFileDetector(new LocalFileDetector()); wd = remoteWebDriver; } else { if (browser == null || browser.equals("")) { throw new RuntimeException( "Browser cannot be null. Please set 'browser' in client properties. Supported browser types: IE, Firefox, Chrome, Safari, HtmlUnit."); } else if (browser.equalsIgnoreCase("ie") || browser.equalsIgnoreCase("iexplore") || browser.equalsIgnoreCase("*iexplore")) { String webdriverIEDriver = properties.getWebDriverIEDriver(); if (webdriverIEDriver != null) { System.setProperty("webdriver.ie.driver", webdriverIEDriver); } String browserVersion = properties.getBrowserVersion(); if (browserVersion == null || browserVersion.equals("")) { throw new RuntimeException( "When using IE as the browser, please set 'browser.version' in client properties"); } else { if (browserVersion.startsWith("9")) { desiredCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); desiredCapabilities.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); wd = new InternetExplorerDriver(desiredCapabilities); } else { wd = new InternetExplorerDriver(desiredCapabilities); } } } else if ((browser.equalsIgnoreCase("firefox") || browser.equalsIgnoreCase("*firefox"))) { final String ffProfileFolder = properties.getFirefoxProfileFolder(); final String ffProfileFile = properties.getFirefoxProfileFile(); final String path = properties.getBinaryPath(); if (path != null) { FirefoxBinary fireFox = getFFBinary(path); FirefoxProfile ffp = null; if (ffProfileFolder != null) { ffp = new FirefoxProfile(new File(ffProfileFolder)); } else { ffp = new FirefoxProfile(); } if (ffProfileFile != null) { addPreferences(ffp, ffProfileFile); } addPreferences(ffp); List<String> ffExtensions = properties.getFirefoxExtensions(); if (ffExtensions != null && ffExtensions.size() > 0) { addExtensionsToFirefoxProfile(ffp, ffExtensions); } wd = new FirefoxDriver(fireFox, ffp, desiredCapabilities); } else { wd = new FirefoxDriver(desiredCapabilities); } } else if (browser.equalsIgnoreCase("chrome")) { String webdriverChromeDriver = properties.getWebDriverChromeDriver(); if (webdriverChromeDriver != null) { System.setProperty("webdriver.chrome.driver", webdriverChromeDriver); } wd = new ChromeDriver(desiredCapabilities); } else if (browser.equalsIgnoreCase("safari")) { wd = new SafariDriver(desiredCapabilities); } else if (browser.equalsIgnoreCase("htmlunit")) { wd = new HtmlUnitDriver(desiredCapabilities); ((HtmlUnitDriver) wd).setJavascriptEnabled(true); } else { throw new Exception("Unsupported browser type: " + browser + ". Supported browser types: IE, Firefox, Chrome, Safari, HtmlUnit."); } // move browser windows to specific position. It's useful for // debugging... final int browserInitPositionX = properties.getBrowserInitPositionX(); final int browserInitPositionY = properties.getBrowserInitPositionY(); if (browserInitPositionX != 0 || browserInitPositionY != 0) { wd.manage().window().setSize(new Dimension(1280, 1024)); wd.manage().window().setPosition(new Point(browserInitPositionX, browserInitPositionY)); } } return wd; }