List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver
public FirefoxDriver()
From source file:barChart1.BarChartDemo.java
License:Open Source License
/** * Starting point for the demonstration application. * * @param args ignored./*from w ww . j a v a2 s.c om*/ */ public static void main(String[] args) { // Demo to buy tickets to the EK 2016 System.out.println("Hello UEFA 2016 !!!"); statistics = ""; JOptionPane.showMessageDialog(null, "Belgium versus Italy demo start"); driver = new FirefoxDriver(); wait = new WebDriverWait(driver, 500); //Open Home Page driver.manage().window().maximize(); driver.get("http://www.uefa.com/"); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div/header/nav/div/div/ul/li/a[text() = 'UEFA EURO 2016']"))); driver.findElement(By.xpath("//div/header/nav/div/div/ul/li/a[text() = 'UEFA EURO 2016']")).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div//nav/div/div/ul/li/a[ text() = 'Teams']"))); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div//nav/div/div/ul/li/a[ text() = 'Matches']"))) .click(); wait.until(ExpectedConditions.visibilityOfElementLocated( By.xpath("//div/div//div//div/a[text() = 'Select your team and follow their EURO journey']"))); driver.findElement( By.xpath("//div/div//div//div/a[text() = 'Select your team and follow their EURO journey']")) .click(); wait2Secs(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div//ul/li/span[text()='Belgium']"))); driver.findElement(By.xpath("//div/div/div//ul/li/span[text()='Belgium']")).click(); // Belgium wait2Secs(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("(//div/table[1]/tbody/tr/td/div/a[text()='21.00'])[1]"))); driver.findElement(By.xpath("(//div/table[1]/tbody/tr/td/div/a[text()='21.00'])[1]")).click(); wait2Secs(); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a/span[text()='Pre-match']"))); // Go to the statistics driver.get("http://www.uefa.com/uefaeuro/season=2016/statistics/index.html"); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a/span[text()='Teams']"))); driver.findElement(By.xpath("//a/span[text()='Teams']")).click(); // Look up the statistics for Belgium and Italy getOverviewStats("BE", "ITA", "Belgium", "Italy"); wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Goals']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Goals']")).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Belgium"); ; wait2Secs(); // getGoalsStats("BE","ITA","Belgium","Italy"); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Attempts']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Attempts']")).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Belgium"); ; wait2Secs(); wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Passes']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Passes']")).click(); wait2Secs(); // Italy wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Italy"); ; wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Overview']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Overview']")).click(); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Italy"); ; wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Goals']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Goals']")).click(); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Italy"); ; wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Attempts']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Attempts']")).click(); driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Italy"); ; wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//div/div/div/ul/li/a[text()='Passes']"))); driver.findElement(By.xpath("//div/div/div/ul/li/a[text()='Passes']")).click(); wait.until(ExpectedConditions .visibilityOfElementLocated(By.xpath("//div/div/div/div/input[@value='Search for a team']"))); driver.findElement(By.xpath("//div/div/div/div/input[@value='Search for a team']")).sendKeys("Italy"); ; driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); JOptionPane.showMessageDialog(null, "Belgium versus Italy : \n" + statistics); BarChartDemo demo = new BarChartDemo("Belgium vs Italy"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setVisible(true); }
From source file:base.GalenTestBase.java
@Override public WebDriver createDriver(Object[] args) { WebDriver driver = new FirefoxDriver(); if (args.length > 0) { if (args[0] != null && args[0] instanceof TestDevice) { TestDevice device = (TestDevice) args[0]; if (device.getScreenSize() != null) { driver.manage().window().setSize(device.getScreenSize()); }/*ww w .j a v a 2 s . c o m*/ } } return driver; }
From source file:basicweb.ElementDisplayed.java
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); // Adding code for JS js = (JavascriptExecutor) driver;/*www. j a va 2 s . co m*/ baseUrl1 = "http://letskodeit.teachable.com/pages/practice"; baseUrl2 = "http://www.expedia.com"; driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS); driver.manage().window().maximize(); }
From source file:basicweb.WorkingWithElementsList.java
@Before public void setUp() throws Exception { driver = new FirefoxDriver(); baseUrl = "http://letskodeit.teachable.com/pages/practice"; // Maximize the browser's window driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); driver.get(baseUrl);//from w ww .ja va 2 s . com }
From source file:be.ugent.mmlab.webdriver.Demo.java
License:Apache License
public void demoTime() throws InterruptedException { // initialize web browser. WebDriver driver = new FirefoxDriver(); // go to the Belgian railways website driver.get("http://www.belgianrail.be"); // select "English" // HTML://from w ww . ja va 2 s . c o m // <a // id="ctl00_bodyPlaceholder_languagesList_ctl02_languageNameLink" // href="javascript:__doPostBack('ctl00$bodyPlaceholder$languagesList$ctl02$languageNameLink','')" // > English </a> WebElement english = driver .findElement(By.id("ctl00_bodyPlaceholder_languagesList_ctl02_languageNameLink")); english.click(); // fill out departure WebElement from = driver.findElement(By.id("departureStationInput")); from.sendKeys("Gent-Dampoort"); // pause for a second to make it not too fast Thread.sleep(1000); // click in the field to get the auto-completion away from.click(); // fill out arrival WebElement to = driver.findElement(By.id("arrivalStationInput")); to.sendKeys("Brussel-Noord"); Thread.sleep(1000); to.click(); // click timetable button WebElement timetableButton = driver.findElement(By.id( "ctl00_ctl00_bodyPlaceholder_bodyPlaceholder_mobilityTimeTableSearch_HomeTabTimeTable1_submitButton")); timetableButton.click(); // get departure info // HTML: // <td headers="hafasOVTimeOUTWARD" class="time"> // <div> // <div class="planed overviewDep"> // 10:00 dep <span class="bold prognosis">+12 min.</span> // </div> // <div class="planed"> // 11:20 arr <span class="bold green">+0 min.</span> // </div> // </div> // </td> List<WebElement> timeCells = driver.findElements(By.className("time")); for (WebElement timeCell : timeCells) { List<WebElement> times = timeCell.findElements(By.className("planed")); System.out.println("----------------------------------------------"); System.out.println("departure time: " + times.get(0).getText()); System.out.println("arrival time: " + times.get(1).getText()); } }
From source file:beseenium.controller.ActionDataFactory.MakeFirefoxData.java
License:Open Source License
@Override public ActionData makeActionData() { return new ActionData(new FirefoxDriver()); }
From source file:bodega.test.selenium.BodegaTest.java
@BeforeClass public static void setUp() throws URISyntaxException { webDriver = new FirefoxDriver(); baseUrl = "http://localhost:8080"; baseUri = new URI("http://localhost:8080"); webDriver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS); }
From source file:botski.example.AddMeFastExample.java
License:Apache License
public void run() { try {//from w w w . j a v a 2 s . c om int likes = 0; int points = 0; long start_time = System.currentTimeMillis(); // Setup Selenium driver = new FirefoxDriver(); jse = (JavascriptExecutor) driver; // Perform the Login actions facebookLogin(); addMeFastLogin(); // Goto the Facebook Likes page driver.get("http://addmefast.com/free_points/facebook_likes.html"); if ("http://addmefast.com/free_points/facebook_likes.html".equals(driver.getCurrentUrl()) == false) { System.err.println( "I was trying to navigate to 'http://addmefast.com/free_points/facebook_likes.html' and ended up here '" + driver.getCurrentUrl() + "'"); return; } // Remember the main window handle String windowHandle = (String) driver.getWindowHandles().toArray()[0]; // Go into the loop while (true) { // Reacts to the appearance of a Like button (new WebDriverWait(driver, 60)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return (Boolean) jse.executeScript( "if(jQuery('.single_like_button').length){return true;}else{return false;}"); } }); // Click the like button by injecting JavaScript to the page jse.executeScript("jQuery('.single_like_button').click();"); // Allow time for the popup window to appear Utils.sleep(1000); // Switch to the new window Set<String> winSet = driver.getWindowHandles(); List<String> winList = new ArrayList<String>(winSet); String newTab = winList.get(winList.size() - 1); driver.switchTo().window(newTab); // switch to new tab // Click the first "Like" button on the page jse.executeScript( "var inputs=document.getElementsByTagName('input');for(var i=0; i<inputs.length; i++){var input=inputs[i];var value=input.getAttribute('value');if(value!=null){if(value=='Like'){input.click();break;}}}"); // Allow time for the Like action to go through Utils.sleep(1000); // Close this window and switch back to the main one driver.close(); driver.switchTo().window(windowHandle); // This delay allows AddMeFast to detect the window close and request the next page to Like Utils.sleep(5000); // Update counters likes++; WebElement points_count = driver.findElement(By.className("points_count")); try { points = Integer.parseInt(points_count.getText()); } catch (Exception ignore) { } long diff = (System.currentTimeMillis() - start_time) / 1000; System.out.println("" + likes + " likes, " + points + " points in " + diff + " seconds"); } } catch (Exception e) { e.printStackTrace(); } }
From source file:br.com.dextraining.selenium.SeleniumTestCase.java
/** * Realiza uma unica instancia do driver, para ser reutilizado em todos os * testes.// w w w. j av a 2 s. c om */ @BeforeClass public static void prepararTeste() { IniciarSistema.start(); driver = new FirefoxDriver(); }
From source file:br.edu.ifpb.praticas.testSystem.FilmeTest.java
@Test public void testCadastro() throws Exception { WebDriver driver = new FirefoxDriver(); WebElement element = driver.findElement(By.name("nome")); // Create a new instance of the Firefox driver // Notice that the remainder of the code relies on the interface, // not the implementation. assertEquals("http://localhost:8085/SisFilme/index.xhtml", driver.getCurrentUrl()); Thread.sleep(2000L);/* w w w. j av a2 s. com*/ element = driver.findElement(By.name("nome")); element.sendKeys("007 contra moscol"); element = driver.findElement(By.name("nome")); element.sendKeys("007 contra moscol"); element = driver.findElement(By.name("ano")); element.sendKeys("2014"); element = driver.findElement(By.name("genero")); element = driver.findElement(By.name("nota")); element.sendKeys("2"); element = driver.findElement(By.name("salvar")); Thread.sleep(2000L); element.click(); assertEquals("http://localhost:8085/SisFilme/gerenciamento.xhtml", driver.getCurrentUrl()); assertNotNull(element); // Wait for the page to load, timeout after 10 seconds (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver d) { return d.getTitle().contains("NetBeans"); } }); //Close the browser driver.quit(); }