List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver(FirefoxDriverService service)
From source file:com.mycompany.newseleniumtest.TestScript2.java
public void startDriver(String browser) { switch (browser) { case "firefox": FirefoxProfile fp = new FirefoxProfile(); fp.setPreference("browser.startup.homepage", "about:blank"); fp.setPreference("startup.homepage_welcome_url", "about:blank"); fp.setPreference("startup.homepage_welcome_url.additional", "about:blank"); this.driver = new FirefoxDriver(fp); this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.manage().window().maximize(); //pras break;//from ww w . jav a 2 s . c o m case "chrome": System.setProperty("webdriver.chrome.driver", "/Users/kevinwibowo/Documents/Project/chromedriver"); this.driver = new ChromeDriver(); this.driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); break; default: break; } }
From source file:com.nabla.project.fronter.selenium.tests.GoogleSearchSTest.java
License:Open Source License
@Before public void setUp() { WindowsUtils.tryToKillByName("firefox.exe"); ProfilesIni allProfiles = new ProfilesIni(); FirefoxProfile profile = allProfiles .getProfile("/workspace/users/albandri10/.mozilla/firefox/xhvt8rwp.selenium/"); // FirefoxProfile profile = new FirefoxProfile(); // FirefoxBinary binary = new FirefoxBinary(new File(firefoxBin)); // driver = new FirefoxDriver(binary, profile); this.driver = new FirefoxDriver(profile); this.driver.manage().window().maximize(); this.driver.get("http://www.google.com"); }
From source file:com.partnet.automation.selenium.AbstractConfigurableDriverProvider.java
License:Apache License
/** * Obtains the default firefox web driver. * //from w w w . ja va 2 s. co m * @return {@link WebDriver} for the Firefox instance */ protected WebDriver getFirefoxWebDriver() { final FirefoxBinary fb; String fireboxBinPath = runConfig.getFirefoxBinaryPath(); if (fireboxBinPath != null) { LOG.info("Using Firefox binary: {}", fireboxBinPath); fb = new FirefoxBinary(new File(fireboxBinPath)); } else { LOG.info("Use system default for the Firefox binary"); fb = new FirefoxBinary(); } final DesiredCapabilities capabilities = getFirefoxCapabilities(); capabilities.setCapability(FirefoxDriver.BINARY, fb); return new FirefoxDriver(capabilities); }
From source file:com.pentaho.selenium.BaseTest.java
License:Apache License
@BeforeSuite public void setUpClass() { this.log.info("Master setup"); // Initialize BASEURL baseUrl = "http://localhost:8080/pentaho/"; downloadDir = System.getProperty("user.home") + "\\SeleniumDonwloadDir"; pentahoReleaseVersion = System.getProperty("pentaho.release.version"); pentahoBaServerServiceName = System.getProperty("pentaho.bi.server.service.name"); pentahoBaServerUrl = System.getProperty("pentaho.bi.server.url"); pentahoBaServerHostname = System.getProperty("pentaho.bi.server.hostname"); pentahoBaServerPort = System.getProperty("pentaho.bi.server.port"); this.log.info("pentaho.release.version::" + pentahoReleaseVersion); new File(downloadDir).mkdir(); System.setProperty("webdriver.log.file", "/dev/stdout"); //System.setProperty( "webdriver.firefox.logfile", "/dev/stdout" ); // Setting log preferences LoggingPreferences logs = new LoggingPreferences(); logs.enable(LogType.BROWSER, Level.WARNING); /*logs.enable( LogType.SERVER, Level.WARNING ); logs.enable( LogType.DRIVER, Level.WARNING ); logs.enable( LogType.PROFILER, Level.WARNING ); logs.enable( LogType.CLIENT, Level.WARNING ); logs.enable( LogType.PERFORMANCE, Level.WARNING );*/ /*/*from w w w .ja v a 2s .co m*/ * INTERNET EXPLORER DRIVER */ // Initialize DRIVER FirefoxProfile ffProfile = new FirefoxProfile(); //ffProfile.setEnableNativeEvents( true ); ffProfile.setPreference("general.useragent.locale", "en-US"); ffProfile.setPreference("intl.accept_languages", "en-US, en"); ffProfile.setPreference("browser.download.folderList", 2); // 0 - Desktop, 1- Download dir, 2 - specify dir ffProfile.setPreference("browser.helperApps.alwaysAsk.force", false); ffProfile.setPreference("browser.download.manager.showWhenStarting", false); ffProfile.setPreference("browser.download.dir", downloadDir); ffProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "table/excel;application/vnd.ms-excel;application/msexcel;application/x-msexcel;application/x-ms-excel;application/x-excel;application/x-dos_ms_excel;application/xls;application/x-xls;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;text/csv;application/rtf"); // Setting properties for webdriver DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs); capabilities.setCapability(FirefoxDriver.PROFILE, ffProfile); BaseTest.driver = new FirefoxDriver(capabilities); /* * INTERNET EXPLORER DRIVER */ /* * System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer_Win32_2.44.0\\IEDriverServer.exe"); * System.setProperty("webdriver.ie.driver.host", "10.120.42.25"); * System.setProperty("webdriver.ie.driver.loglevel", "FATAL"); System.setProperty("webdriver.ie.driver.loglevel", * downloadDir + "\\seleniumlogs.txt"); * * // We could use any driver for our tests... DesiredCapabilities capabilities = new DesiredCapabilities(); * capabilities.setBrowserName("internet explorer"); capabilities.setVersion("8"); * capabilities.setPlatform(Platform.WINDOWS); capabilities.setCapability("platform", "WINDOWS"); * capabilities.setJavascriptEnabled(true); //capabilities.setCapability(InternetExplorerDriver.HOST, * "10.120.40.243"); * * capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); * capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); * * // Get a handle to the driver. This will throw an exception // if a matching driver cannot be located driver = * new RemoteWebDriver(new URL("http://10.120.42.25:4444/wd/hub"), capabilities); //driver = new * InternetExplorerDriver(); */ BaseTest.driver.manage().window().setPosition(new Point(0, 0)); BaseTest.driver.manage().window().setSize(new Dimension(1360, 764)); BaseTest.driver.manage().timeouts().pageLoadTimeout(180, TimeUnit.SECONDS); BaseTest.driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); BaseTest.driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS); // Initialize WAIT wait = new FluentWait<WebDriver>(BaseTest.driver).withTimeout(30, TimeUnit.SECONDS).pollingEvery(5, TimeUnit.SECONDS); }
From source file:com.pluribus.vcf.helper.TestSetup.java
public void startDriver(String vcfIp, String browserName) { if (browserName.equalsIgnoreCase("chrome")) { System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver"); DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome(); handlSSLErr.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); driver = new ChromeDriver(handlSSLErr); driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.get("https:" + vcfIp); } else if (browserName.equalsIgnoreCase("firefox")) { /*//from w w w .j a v a2s. co m //Class ProfilesIni details ProfilesIni allProfiles = new ProfilesIni(); // Use FirefoxProfile Constructor FirefoxProfile myProfile = allProfiles.getProfile("CertificateIssue"); myProfile.setAcceptUntrustedCertificates(true); myProfile.setAssumeUntrustedCertificateIssuer(false); driver = new FirefoxDriver(myProfile); */ System.setProperty("webdriver.gecko.driver", "src/test/resources/geckodriver"); DesiredCapabilities caps = DesiredCapabilities.firefox(); caps.setCapability("marionette", true); caps.setCapability("acceptInsecureCerts", true); //var capabilities = new FirefoxOptions().addTo(caps); System.out.println("Capabilities:" + caps.toString()); driver = new FirefoxDriver(caps); driver.get("https:" + vcfIp); System.out.println("title" + driver.getTitle()); } //TODO: ADD IE AND SAFARI TO THE LIST }
From source file:com.raja.anucarita.SeWrapper.java
License:Open Source License
public static WebDriver getDriver() throws Exception { if (Browser.equals("Firefox")) { FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("capability.policy.default.Window.QueryInterface", "allAccess"); profile.setPreference("capability.policy.default.Window.frameElement.get", "allAccess"); driver = new FirefoxDriver(profile); } else if (Browser.equals("IE")) { driver = new InternetExplorerDriver(); } else if (Browser.equals("GoogleChrome")) { System.setProperty("webdriver.chrome.driver", values.getProperty("GoogleChromeLocation")); driver = new ChromeDriver(); } else {/*from w w w. j av a2 s .c o m*/ throw new Exception("Browser String is wrong"); } return driver; }
From source file:com.redspr.redrobot.WebDriverRobot.java
License:Open Source License
public WebDriverRobot() { DesiredCapabilities dc = DesiredCapabilities.firefox(); dc.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE); WebDriver ff = new FirefoxDriver(dc); init(ff);/*from w w w. j a v a 2 s.com*/ }
From source file:com.sat.dbds.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Opens the Firefox instance for Selenium. *///from w w w. j av a2 s. c o m public static void openBrowser() { if (System.getProperty("run.type") == null || System.getProperty("run.type").equalsIgnoreCase("WUI")) { if (getDriver() != null) System.out.println(getDriver().toString() + "hi"); if (getDriver() == null || (!getDriver().toString().contains("-"))) { try { String browser = Validate.readsystemvariable("browser"); LogHandler.info("Browser:" + browser); String digest = Validate.readsystemvariable("browser.digest"); LogHandler.info("Digest Auth:" + digest); if (browser.equals("firefox") && digest.toUpperCase().equals("YES")) { LogHandler.info("Fire Fox Driver with addon configuration"); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.link.open_newwindow", 2); File extentions = new File(System.getProperty("user.dir") + Validate.readsystemvariable("firefox.addons.path")); if (extentions.exists()) { for (File extention : extentions.listFiles()) { if (extention.getName().endsWith(".xpi")) { try { profile.addExtension(new File(extention.getAbsolutePath())); } catch (IOException e) { Assert.assertTrue( "Exception occured while adding the extension to the profile..", false); } LogHandler.info("Added extention: " + extention.getName()); } } } driver = new FirefoxDriver(profile); } else if (browser.equals("firefox") && digest.toUpperCase().equals("NO")) { LogHandler.info("Fire Fox Driver without addon configuration"); driver = new FirefoxDriver(); } else if (browser.equals("chrome")) { LogHandler.info("Chrome Driver configuration"); JarFile jarFile = jarfilehandler.jarForClass(SeleniumUtilities.class); jarfilehandler.copyResourcesToDirectory(jarFile, "chrome", "src/it/resources/chrome"); System.setProperty("webdriver.chrome.driver", "src/it/resources/chrome/chromedriver.exe"); driver = new ChromeDriver(); } else if (browser.equals("IE")) { LogHandler.info("IE Driver configuration"); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); String IEpath = (SeleniumUtilities.class).getResource("").getPath(); System.out.println(IEpath.substring(0, IEpath.length() - 31)); capabilities.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); JarFile jarFile = jarfilehandler.jarForClass(SeleniumUtilities.class); // JarFile jarFile = new // JarFile("C:\\Users\\amsathishkumar\\.m2\\repository\\com\\cisco\\dbds\\Utils\\0.0.1-Release\\Utils-0.0.1-Release.jar"); jarfilehandler.copyResourcesToDirectory(jarFile, "internetexplorer", "src/it/resources/InternetExplorer"); System.setProperty("webdriver.ie.driver", "src/it/resources/internetexplorer/IEDriverServer.exe"); driver = new InternetExplorerDriver(capabilities); // driver = new InternetExplorerDriver(); } else { Assert.assertTrue("include the browswer variable...", false); } } catch (Exception e) { LogHandler.info("Check the varaiables: browser,firefox.addons.path,user.dir"); } // driver.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS); // driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(Integer.parseInt(System.getProperty("implicit.wait")), TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(Integer.parseInt(System.getProperty("explicit.wait")), TimeUnit.SECONDS); System.out.println(getDriver().toString() + "hi"); } } }
From source file:com.sat.spvgt.utils.selenium.SeleniumUtilities.java
License:Open Source License
/** * Opens the Firefox instance for Selenium. *//*ww w. j a va 2 s .c o m*/ public static void openBrowser() { if (System.getProperty("run.type") == null) { try { if (getDriver() == null || (!getDriver().toString().contains("-"))) { String browser = miscValidate.readsystemvariable("browser"); LogHandler.info("Browser:" + browser); String digest = miscValidate.readsystemvariable("browser.digest"); LogHandler.info("Digest Auth:" + digest); if (browser.equals("firefox") && digest.toUpperCase().equals("YES")) { LogHandler.info("Fire Fox Driver with addon configuration"); FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("browser.link.open_newwindow", 2); File extentions = new File(System.getProperty("user.dir") + miscValidate.readsystemvariable("firefox.addons.path")); if (extentions.exists()) { for (File extention : extentions.listFiles()) { if (extention.getName().endsWith(".xpi")) { try { profile.addExtension(new File(extention.getAbsolutePath())); } catch (IOException e) { Assert.assertTrue( "Exception occured while adding the extension to the profile..", false); } LogHandler.info("Added extention: " + extention.getName()); } } } driver = new FirefoxDriver(profile); } else if (browser.equals("firefox") && digest.toUpperCase().equals("NO")) { LogHandler.info("Fire Fox Driver without addon configuration"); driver = new FirefoxDriver(); } else if (browser.equals("chrome")) { LogHandler.info("Chrome Driver configuration"); JarFile jarFile = miscJarfileHandler.jarForClass(SeleniumUtilities.class); miscJarfileHandler.copyResourcesToDirectory(jarFile, "chrome", "src/it/resources/chrome"); System.setProperty("webdriver.chrome.driver", "src/it/resources/chrome/chromedriver.exe"); driver = new ChromeDriver(); } else if (browser.equals("IE")) { LogHandler.info("IE Driver configuration"); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); String IEpath = (SeleniumUtilities.class).getResource("").getPath(); System.out.println(IEpath.substring(0, IEpath.length() - 31)); capabilities.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); JarFile jarFile = miscJarfileHandler.jarForClass(SeleniumUtilities.class); // JarFile jarFile = new // JarFile("C:\\Users\\amsathishkumar\\.m2\\repository\\com\\cisco\\dbds\\Utils\\0.0.1-Release\\Utils-0.0.1-Release.jar"); miscJarfileHandler.copyResourcesToDirectory(jarFile, "internetexplorer", "src/it/resources/InternetExplorer"); System.setProperty("webdriver.ie.driver", "src/it/resources/internetexplorer/IEDriverServer.exe"); driver = new InternetExplorerDriver(capabilities); // driver = new InternetExplorerDriver(); } else { Assert.assertTrue("include the browswer variable...", false); } } } catch (Exception e) { LogHandler.info("Check the varaiables: browser,firefox.addons.path,user.dir"); } // driver.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS); // driver.manage().timeouts().setScriptTimeout(10, // TimeUnit.SECONDS); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(Integer.parseInt(System.getProperty("implicit.wait")), TimeUnit.SECONDS); driver.manage().timeouts().pageLoadTimeout(Integer.parseInt(System.getProperty("explicit.wait")), TimeUnit.SECONDS); } }
From source file:com.screenslicer.core.scrape.Scrape.java
License:Open Source License
private static void start(int pageLoadTimeout, Proxy proxy) { for (int i = 0; i < RETRIES; i++) { try {//from w ww .j av a 2 s . c o m FirefoxProfile profile = new FirefoxProfile(new File("./firefox-profile")); if (proxy != null) { if (!CommonUtil.isEmpty(proxy.username) || !CommonUtil.isEmpty(proxy.password)) { String user = proxy.username == null ? "" : proxy.username; String pass = proxy.password == null ? "" : proxy.password; profile.setPreference("extensions.closeproxyauth.authtoken", Base64.encodeBase64String((user + ":" + pass).getBytes("utf-8"))); } else { profile.setPreference("extensions.closeproxyauth.authtoken", ""); } if (Proxy.TYPE_SOCKS_5.equals(proxy.type) || Proxy.TYPE_SOCKS_4.equals(proxy.type)) { profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.socks", proxy.ip); profile.setPreference("network.proxy.socks_port", proxy.port); profile.setPreference("network.proxy.socks_remote_dns", true); profile.setPreference("network.proxy.socks_version", Proxy.TYPE_SOCKS_5.equals(proxy.type) ? 5 : 4); } else if (Proxy.TYPE_SSL.equals(proxy.type)) { profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.ssl", proxy.ip); profile.setPreference("network.proxy.ssl_port", proxy.port); } else if (Proxy.TYPE_HTTP.equals(proxy.type)) { profile.setPreference("network.proxy.type", 1); profile.setPreference("network.proxy.http", proxy.ip); profile.setPreference("network.proxy.http_port", proxy.port); } } driver = new FirefoxDriver(profile); driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS); driver.manage().timeouts().setScriptTimeout(pageLoadTimeout, TimeUnit.SECONDS); driver.manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS); break; } catch (Throwable t1) { if (driver != null) { try { forceQuit(); driver = null; } catch (Throwable t2) { Log.exception(t2); } } Log.exception(t1); } } }