List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver()
From source file:com.grupo2s.demo.event2s.ReservarEventoEmbebidoTest.java
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); String baseUrl = "http://demo.event2s.com/"; wait = new WebDriverWait(driver, 10); selenium = new WebDriverBackedSelenium(driver, baseUrl); }
From source file:com.hp.test.framework.Reporting.screenshot.java
public static void generatescreenshot(String html_path, String Screenshot_file_path) throws MalformedURLException, FileNotFoundException, IOException { try {//from w w w. ja v a2 s .co m WebDriver driver = new FirefoxDriver(); driver.manage().window().maximize(); driver.get("file:///" + html_path);//+C:/Users/yanamalp/Desktop/DS_Latest/DSIntegrationTest/ATU%20Reports/Results/Run_3/CurrentRun.html"); new Select(driver.findElement(By.id("tcFilter"))).selectByVisibleText("Skipped Test Cases"); File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); // Now you can do whatever you need to do with it, for example copy somewhere FileUtils.copyFile(scrFile, new File(Screenshot_file_path)); driver.quit(); } catch (Exception e) { log.error("Error in getting Screen shot for the Last run" + e.getMessage()); } }
From source file:com.ibm.sbt.automation.core.environment.TestEnvironment.java
License:Open Source License
/** * Return the WebDriver/* w ww. j a v a 2 s. c o m*/ * * @return {WebDriver} */ public WebDriver getWebDriver() { // browser to test with assertTrue("Requesting webdriver while using the mock transport: " + System.getProperty("testMode"), System.getProperty("testMode") == null); String browserName = System.getProperty(PROP_BROWSER); if (webDriver == null) { logger.info("Creating WebDriver instance"); if (StringUtil.isEmpty(System.getProperty(SELENIUM_HUB))) { if ("ie".equals(browserName)) { initInternetExplorerDriver(); } else if ("chrome".equals(browserName)) { initChromeDriver(); } else if ("safari".equals(browserName)) { webDriver = new SafariDriver(); } else if ("headless".equals(browserName)) { HtmlUnitDriver driver = new HtmlUnitDriver(true); webDriver = driver; } else { webDriver = new FirefoxDriver(); } } else { DesiredCapabilities cap = null; if ("ie".equals(browserName)) { cap = DesiredCapabilities.internetExplorer(); } else if ("chrome".equals(browserName)) { cap = DesiredCapabilities.chrome(); } else if ("safari".equals(browserName)) { cap = DesiredCapabilities.safari(); } else if ("headless".equals(browserName)) { cap = DesiredCapabilities.htmlUnit(); } else { cap = DesiredCapabilities.firefox(); } cap.setCapability(CapabilityType.TAKES_SCREENSHOT, true); cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); try { webDriver = new RemoteWebDriver(new URL(System.getProperty(SELENIUM_HUB)), cap); webDriver = new Augmenter().augment(webDriver); } catch (MalformedURLException e) { throw new RuntimeException(e); } } } return webDriver; }
From source file:com.ibm.watson.movieapp.dialog.fvt.config.Driver.java
License:Open Source License
/** * getInstance() /*from ww w . jav a 2s . c om*/ * @return RemoteWebDriver */ public WebDriver getInstance() { WebDriver driver = null; String browser = Utils.readConfigProperty("browser"); if (seleniumGridServer.isEmpty()) { logger.info("INFO: Using local client for GUI Automation"); driver = new FirefoxDriver(); } else { try { logger.info("INFO: Using selenium grid for GUI Automation"); DesiredCapabilities capability; if (browser.contains("firefox")) { capability = DesiredCapabilities.firefox(); } else if (browser.contains("chrome")) { capability = DesiredCapabilities.chrome(); } else { throw new RuntimeException( "WebDriver initialisation is not defined for this BrowserType: " + browser); } driver = new RemoteWebDriver(new URL(seleniumGridServer), capability); } catch (MalformedURLException e) { e.printStackTrace(); } } driver.manage().window().maximize(); return driver; }
From source file:com.inc108.webdriver2.MyFirstTest.java
@Test public void startWebDriver() { WebDriver driver = new FirefoxDriver(); driver.navigate().to("http://ww16.sec.cl/ciige3/"); if (driver instanceof JavascriptExecutor) { ((JavascriptExecutor) driver).executeScript("console.log('im js from webdriver selenium!!!');"); }/*from w w w. j a v a 2 s . c o m*/ String[] units = { "12", "13", "15", "22", "24", "25", "26", "31", "32", "33", "35", "37", "41", "44", "46", "51", "52", "53", "54", "56", "57", "61", "62", "63", "64", "66", "71", "72", "73", "74", "77", "81", "82", "83", "84", "85", "86", "87", "91", "92", "93", "94", "95", "96", "97", "101", "102", "103", "104", "105", "106", "107", "111", "112", "113", "114", "115", "116", "121", "122", "124", "125", "126", "127", "131", "134", "141", "142", "143", "145", "151", "152", "155", "157", "161", "162", "164", "165", "166", "167", "171", "173", "175", "181", "182", "183", "185", "186", "191", "192", "193", "195", "197" }; String cigeNumber = "835805"; driver.findElement(By.xpath( ".//*[@id='cuerpo']/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[1]/td[2]/input")) .sendKeys("13.432.595-k"); driver.findElement(By.xpath( ".//*[@id='cuerpo']/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[2]/td[2]/input")) .sendKeys("76.001.876-7"); driver.findElement(By.xpath( ".//*[@id='cuerpo']/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[3]/td[2]/input")) .sendKeys("vre8401"); //click aceptar driver.findElement(By.xpath( ".//*[@id='cuerpo']/table/tbody/tr[2]/td/table/tbody/tr/td[2]/table/tbody/tr[1]/td/table[2]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr/td/table/tbody/tr[5]/td[2]/a[1]")) .click(); //click procesos en construccion driver.findElement(By.xpath( ".//*[@id='menu']/tbody/tr[2]/td/table/tbody/tr[2]/td/table/tbody/tr[1]/td[2]/table/tbody/tr[7]/td/div/a")) .click(); //enter proceso id driver.findElement(By.xpath( ".//*[@id='cuerpo']/table/tbody/tr/td/table[2]/tbody/tr[1]/td[2]/form/table/tbody/tr[2]/td[2]/input")) // .sendKeys("840480"); .sendKeys(cigeNumber); //click buscar driver.findElement(By.xpath(".//*[@id='cuerpo']/table/tbody/tr/td/table[2]/tbody/tr[1]/td[2]/form/a")) .click(); //click on cige number link driver.findElement(By.xpath(".//*[@id='tabla']/tbody/tr/td[1]/a")).click(); //paso uno - click siguiente driver.findElement(By.xpath(".//*[@id='Tabla_01']/tbody/tr/td/a")).click(); //paso 2 - click siguiente driver.findElement(By.xpath(".//*[@id='Tabla_01']/tbody/tr/td[3]/a")).click(); // Assert.assertTrue("title should start with selenium simplified", driver.getTitle().startsWith("Selenium Simplified")); // driver.close(); // driver.quit(); }
From source file:com.jase.knife.BrowserEmulator.java
License:Apache License
public BrowserEmulator() { int browserType = GlobalSettings.browserCoreType; if (browserType == 1) { browser = new FirefoxDriver(); } else if (browserType == 2) { browser = new ChromeDriver(); } else if (browserType == 3) { browser = new InternetExplorerDriver(); } else if (browserType == 4) { browser = new EdgeDriver(); } else if (browserType == 5) { browser = new OperaDriver(); } else if (browserType == 6) { browser = new PhantomJSDriver(); } else {// w w w . java2 s . co m Assert.fail("Not found browser, See the 'prop.properties' file, configure the browser type."); } }
From source file:com.java.xerotests.EmployeeCreationTests.java
private void setParameterValues(TestDataObj TestDataObject) { try {//from ww w .j a v a 2 s . c o m driver = new FirefoxDriver(); driver.manage().window().maximize(); sTestCaseID = TestDataObject.getTestcaseID(); sParam0 = TestDataObject.getParam0(); sParam1 = TestDataObject.getParam1(); sParam2 = TestDataObject.getParam2(); sParam3 = TestDataObject.getParam3(); sParam4 = TestDataObject.getParam4(); sParam5 = TestDataObject.getParam5(); sParam6 = TestDataObject.getParam6(); sParam7 = TestDataObject.getParam7(); sParam8 = TestDataObject.getParam8(); sParam9 = TestDataObject.getParam9(); sParam10 = TestDataObject.getParam10(); sParam11 = TestDataObject.getParam11(); sParam12 = TestDataObject.getParam12(); sParam13 = TestDataObject.getParam13(); sParam14 = TestDataObject.getParam14(); sParam15 = TestDataObject.getParam15(); sParam16 = TestDataObject.getParam16(); sParam17 = TestDataObject.getParam17(); sParam18 = TestDataObject.getParam18(); sParam19 = TestDataObject.getParam19(); sParam20 = TestDataObject.getParam20(); generalFunctions = PageFactory.initElements(driver, GeneralFunctions.class); employeeCreationPage = PageFactory.initElements(driver, EmployeeCreationPage.class); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.javacreed.examples.misc.Example.java
License:Apache License
public static void main(final String[] args) throws Exception { final String link = "http://www.javacreed.com/"; final File screenShot = new File("screenshot.png").getAbsoluteFile(); Example.LOGGER.debug("Creating Firefox Driver"); final WebDriver driver = new FirefoxDriver(); try {//www. j av a 2 s .c o m Example.LOGGER.debug("Opening page: {}", link); driver.get(link); Example.LOGGER.debug("Wait a bit for the page to render"); TimeUnit.SECONDS.sleep(5); Example.LOGGER.debug("Taking Screenshot"); final File outputFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(outputFile, screenShot); Example.LOGGER.debug("Screenshot saved: {}", screenShot); } finally { driver.close(); } Example.LOGGER.debug("done"); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void openWikiEnglishFirefox() throws InterruptedException { /*/*from w w w . ja va 2 s .c o m*/ 1. Launch Firefox 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Close Firefox */ driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(10000); driver.quit(); }
From source file:com.jpablo.test.NavigateWikipedia.java
public void doSearchWikiENFF(String sendKeys) throws InterruptedException { /*/*from w w w. j av a2 s .c o m*/ 1. Launch Firefox 2. Open Wikipedia main page 3. Open Wikipedia in English 4. Type a word to search 5. Click on Search button 6. Close Firefox */ driver = new FirefoxDriver(); driver.get("http://www.wikipedia.org"); link = driver.findElement(By.linkText("English")); link.click(); Thread.sleep(10000); searchBox = driver.findElement(By.id("searchInput")); searchBox.sendKeys(sendKeys); searchBox.submit(); Thread.sleep(5000); driver.quit(); }