List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver()
From source file:com.kurento.test.selenium.MixerTst.java
License:Open Source License
private WebDriver createDriver(Class<? extends WebDriver> driverClass) { WebDriver driver = null;/*w ww.j a va 2 s . c o m*/ if (driverClass.equals(FirefoxDriver.class)) { driver = new FirefoxDriver(); } else if (driverClass.equals(ChromeDriver.class)) { String chromedriver = null; if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) { chromedriver = "chromedriver"; } else if (SystemUtils.IS_OS_WINDOWS) { chromedriver = "chromedriver.exe"; } System.setProperty("webdriver.chrome.driver", new File("target/webdriver/" + chromedriver).getAbsolutePath()); ChromeOptions options = new ChromeOptions(); // This flag avoids a warning in chrome. See: // https://code.google.com/p/chromedriver/issues/detail?id=799 options.addArguments("--test-type"); // This flag avoids grant the camera options.addArguments("--use-fake-ui-for-media-stream"); // This flag makes using a synthetic video (green with // spinner) in webrtc. Or it is needed to combine with // use-file-for-fake-video-capture to use a file faking the // cam options.addArguments("--use-fake-device-for-media-stream"); driver = new ChromeDriver(options); } return driver; }
From source file:com.kurento.test.selenium.WebRtcTst.java
License:Open Source License
private void setup(Class<? extends WebDriver> driverClass) { if (driverClass.equals(FirefoxDriver.class)) { driver = new FirefoxDriver(); } else if (driverClass.equals(ChromeDriver.class)) { String chromedriver = null; if (SystemUtils.IS_OS_MAC || SystemUtils.IS_OS_LINUX) { chromedriver = "chromedriver"; } else if (SystemUtils.IS_OS_WINDOWS) { chromedriver = "chromedriver.exe"; }//from w ww.j a v a 2 s.com System.setProperty("webdriver.chrome.driver", new File("target/webdriver/" + chromedriver).getAbsolutePath()); ChromeOptions options = new ChromeOptions(); // This flag avoids a warning in chrome. See: // https://code.google.com/p/chromedriver/issues/detail?id=799 options.addArguments("--test-type"); // This flag avoids grant the camera options.addArguments("--use-fake-ui-for-media-stream"); // This flag makes using a synthetic video (green with // spinner) in webrtc. Or it is needed to combine with // use-file-for-fake-video-capture to use a file faking the // cam options.addArguments("--use-fake-device-for-media-stream"); driver = new ChromeDriver(options); } }
From source file:com.linagora.obm.ui.ioc.Module.java
License:Open Source License
@Override protected void configure() { bind(URL.class).annotatedWith(Names.named(SERVER_URL)).toInstance(readRequiredUrlArg(SERVER_URL)); URL clientUrl = readUrlArg(CLIENT_URL); if (clientUrl != null) { bind(WebDriver.class).toInstance(new RemoteWebDriver(clientUrl, buildDriverCapabilities())); } else {//from www. jav a 2 s.c o m bind(WebDriver.class).toInstance(new FirefoxDriver()); } }
From source file:com.maoyan.pf.webcollector.spider.ShowrateCrawler.java
License:Open Source License
public static void main(String[] args) throws Exception { Executor executor = new Executor() { @Override// ww w.j a v a 2 s .c o m public void execute(CrawlDatum datum, CrawlDatums next) throws Exception { MongoClient mongoClient = new MongoClient("localhost", 27017); // ? // DBCollection dbCollection = mongoClient.getDB("maoyan_crawler").getCollection("rankings_am"); DB db = mongoClient.getDB("maoyan_crawler"); // ????? Set<String> colls = db.getCollectionNames(); for (String s : colls) { // Collection(?"") if (s.equals("show_rate")) { db.getCollection(s).drop(); } } DBCollection dbCollection = db.getCollection("show_rate"); // ProfilesIni pi = new ProfilesIni(); // FirefoxProfile profile = pi.getProfile("default"); WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.manage().timeouts().pageLoadTimeout(3, TimeUnit.SECONDS); // driver.setJavascriptEnabled(false); System.out.println("??\n"); driver.get(datum.getUrl()); // System.out.println(driver.getPageSource()); List<WebElement> movie_name = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c1 lineDot']")); List<WebElement> boxoffice_rate = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c2 red']")); List<WebElement> visit_pershow = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c3 gray']")); WebElement title = driver.findElement(By.xpath("//p[@id='pieTip']")); for (int i = 0; i < movie_name.size(); i++) { String movie_name_val = movie_name.get(i).getText(); String boxofficerate_val = boxoffice_rate.get(i).getText(); String visit_pershow_val = visit_pershow.get(i).getText(); BasicDBObject dbObject = new BasicDBObject(); dbObject.append("title", title.getText()).append("is_gold", "?") .append("show_type", "?").append("movie_name", movie_name_val) .append("boxoffice_rate", boxofficerate_val).append("visit_pershow", visit_pershow_val); dbCollection.insert(dbObject); } System.out.println("?\n"); WebElement click_gold = driver.findElement(By.id("playPlan_time")); click_gold.click(); String gold_seat = driver.getWindowHandle(); driver.switchTo().window(gold_seat); List<WebElement> movie_name_gold = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c1 lineDot']")); List<WebElement> boxoffice_rate_gold = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c2 red']")); List<WebElement> visit_pershow_gold = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c3 gray']")); WebElement title_gold = driver.findElement(By.xpath("//p[@id='pieTip']")); for (int i = 0; i < movie_name_gold.size(); i++) { String movie_name_val = movie_name_gold.get(i).getText(); String boxofficerate_val = boxoffice_rate_gold.get(i).getText(); String visit_pershow_val = visit_pershow_gold.get(i).getText(); BasicDBObject dbObject = new BasicDBObject(); dbObject.append("title", title_gold.getText()).append("is_gold", "") .append("show_type", "?").append("movie_name", movie_name_val) .append("boxoffice_rate", boxofficerate_val).append("visit_pershow", visit_pershow_val); dbCollection.insert(dbObject); } System.out.println("?\n"); WebElement click_vist = driver.findElement(By.xpath("//*[@id='show--type']")); click_vist.click(); String gold_vist = driver.getWindowHandle(); driver.switchTo().window(gold_vist); List<WebElement> movie_name_gold_visit = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c1 lineDot']")); List<WebElement> boxoffice_rate_gold_visit = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c2 red']")); List<WebElement> visit_pershow_gold_visit = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c3 gray']")); WebElement title_gold_visit = driver.findElement(By.xpath("//p[@id='pieTip']")); for (int i = 0; i < movie_name_gold_visit.size(); i++) { String movie_name_val = movie_name_gold_visit.get(i).getText(); String boxofficerate_val = boxoffice_rate_gold_visit.get(i).getText(); String visit_pershow_val = visit_pershow_gold_visit.get(i).getText(); BasicDBObject dbObject = new BasicDBObject(); dbObject.append("title", title_gold_visit.getText()).append("is_gold", "") .append("show_type", "").append("movie_name", movie_name_val) .append("boxoffice_rate", boxofficerate_val).append("visit_pershow", visit_pershow_val); dbCollection.insert(dbObject); } System.out.println("?\n"); click_gold.click(); String normal_seat = driver.getWindowHandle(); driver.switchTo().window(normal_seat); List<WebElement> movie_name_normal_seat = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c1 lineDot']")); List<WebElement> boxoffice_rate_normal_seat = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c2 red']")); List<WebElement> visit_pershow_normal_seat = driver .findElements(By.xpath("//div[@id='playPlan_table']/ul/li[@class='c3 gray']")); WebElement title_normal_seat = driver.findElement(By.xpath("//p[@id='pieTip']")); for (int i = 0; i < movie_name_normal_seat.size(); i++) { String movie_name_val = movie_name_normal_seat.get(i).getText(); String boxofficerate_val = boxoffice_rate_normal_seat.get(i).getText(); String visit_pershow_val = visit_pershow_normal_seat.get(i).getText(); BasicDBObject dbObject = new BasicDBObject(); dbObject.append("title", title_normal_seat.getText()).append("is_gold", "?") .append("show_type", "").append("movie_name", movie_name_val) .append("boxoffice_rate", boxofficerate_val).append("visit_pershow", visit_pershow_val); dbCollection.insert(dbObject); } driver.close(); driver.quit(); mongoClient.close(); } }; //DBDBManager DBManager manager = new BerkeleyDBManager("maoyan"); //Crawler?DBManagerExecutor Crawler crawler = new Crawler(manager, executor); crawler.addSeed("http://pf.maoyan.com/show/rate"); crawler.start(1); }
From source file:com.michaelpidde.testflow.engine.util.TestSuite.java
License:Open Source License
public void setup() { switch (browser) { case "ff": driver = new FirefoxDriver(); break;/*w w w . ja v a2 s. c o m*/ case "ie": try { service = new InternetExplorerDriverService.Builder() .usingDriverExecutable(new File(runPath + "\\IEDriverServer.exe")).usingAnyFreePort() .build(); ((InternetExplorerDriverService) service).start(); DesiredCapabilities ieOptions = DesiredCapabilities.internetExplorer(); ieOptions.setCapability("ignoreProtectedModeSettings", true); driver = new RemoteWebDriver(((InternetExplorerDriverService) service).getUrl(), ieOptions); driver = new Augmenter().augment(driver); } catch (NullPointerException e) { System.out.println(e.toString()); } catch (IOException e) { System.out.println(e.toString()); } break; case "chrome": try { service = new ChromeDriverService.Builder() .usingDriverExecutable(new File(runPath + "\\chromedriver.exe")).usingAnyFreePort().build(); ((ChromeDriverService) service).start(); DesiredCapabilities chromeOptions = DesiredCapabilities.chrome(); chromeOptions.setCapability("chrome.switches", Arrays.asList("--start-maximized")); driver = new RemoteWebDriver(((ChromeDriverService) service).getUrl(), chromeOptions); driver = new Augmenter().augment(driver); } catch (NullPointerException e) { System.out.println(e.toString()); } catch (IOException e) { System.out.println(e.toString()); } break; } // Set a wait period for finding elements, max of 10 seconds. driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); // Set up logger logger.setDriver(driver); // Start test suite run. driver.get(baseUrl); /* * This is not used currently. It's a step retained from legacy code, but I want * to leave it for now due to its potentially useful nature. A better way to do * this would be to change it to a test of the baseUrl and checking by response * (i.e. 404, 500, 501, etc.). */ // Do a quick smoke test to see if the URL has any errors on it. // CFError cferror = new CFError(driver, baseUrl, logger); // boolean error = false; // try { // error = cferror.run(); // } catch(TestException e) { // // Don't do anything with this error at this time. // } // if(error) { // runSuite = false; // } }
From source file:com.mobileobservinglog.ngcdata.SeleniumIC.java
License:Open Source License
public SeleniumIC() { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); }
From source file:com.molo.dagger.BrowserEmulator.java
License:Apache License
private void setupBrowserCoreType(int type) { if (type == 1) { browserCore = new FirefoxDriver(); logger.info("Using Firefox"); return;//from w ww . jav a 2s .com } if (type == 2) { chromeServer = new ChromeDriverService.Builder() .usingDriverExecutable(new File(GlobalSettings.chromeDriverPath)).usingAnyFreePort().build(); try { chromeServer.start(); } catch (IOException e) { e.printStackTrace(); } DesiredCapabilities capabilities = DesiredCapabilities.chrome(); capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized")); // browserCore = new RemoteWebDriver(chromeServer.getUrl(), capabilities); browserCore = new ChromeDriver(chromeServer, capabilities); logger.info("Using Chrome"); return; } if (type == 3) { System.setProperty("webdriver.ie.driver", GlobalSettings.ieDriverPath); DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); browserCore = new InternetExplorerDriver(capabilities); logger.info("Using IE"); return; } if (type == 4) { browserCore = new SafariDriver(); logger.info("Using Safari"); return; } Assert.fail("Incorrect browser type"); }
From source file:com.mvnsnm.LoginIT.java
@BeforeClass public static void setUpClass() { properties = AppProperties.getProperties(); driver = new FirefoxDriver(); rs = new Reuseable(driver); rgs = new Register(driver); tbv = new Tabviews(driver); driver.get("http://localhost:8801"); driver.manage().window().maximize(); }
From source file:com.mycompany.browserManipulationUtilities.BrowserCalibration.java
@BeforeClass public static void setUpClass() { browser = new FirefoxDriver(); }
From source file:com.mycompany.firstmavenproject.DriverFactory.java
public static WebDriver create(String type) { WebDriver driver = null;/*from w ww.j av a 2 s . co m*/ if (type.contains("FirefoxDriver")) { driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); } else if (type.contains("ChromeDriver")) { driver = new ChromeDriver(); } else if (type.contains("InternetExplorerDriver")) { driver = new InternetExplorerDriver(); } else if (type.contains("OperaDriver")) { driver = new OperaDriver(); } else if (type.contains("SafariDriver")) { driver = new SafariDriver(); } return driver; }