Example usage for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver

List of usage examples for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver

Introduction

In this page you can find the example usage for org.openqa.selenium.firefox FirefoxDriver FirefoxDriver.

Prototype

public FirefoxDriver() 

Source Link

Usage

From source file:com.mycompany.newseleniumtest.coba.java

public void latihan(String browser) throws InterruptedException {
    //Instantiate the webdriver object:
    WebDriver driver = new FirefoxDriver();
    JavascriptExecutor jse = (JavascriptExecutor) driver;

    //Open the web
    driver.get("http://dev.uangteman.com/admin/");
    driver.manage().window().maximize();

    Thread.sleep(1500);//from   ww  w  .j av a2 s .c  o m
    driver.findElement(By.name("bu_name")).sendKeys("rahmat_cs");
    driver.findElement(By.name("bu_passwd")).sendKeys("testing");
    driver.findElement(By.cssSelector("button[class='btn btn-orange btn-squared pull-right ladda-button']"))
            .click();

    Thread.sleep(2500);
    jse.executeScript("window.scrollBy(0,1500)", "");
    jse.executeScript("window.scroll(0,1500)", "");

    WebElement scroll = driver.findElement(By.xpath(
            "/html/body/div[2]/div[2]/div/div[2]/div/div/div[3]/div/div[2]/div/form/table/tbody/tr[1]/td[12]/span"));
    JavascriptExecutor js = (JavascriptExecutor) driver;
    jse.executeScript(
            "document.getElementByxpath('/html/body/div[2]/div[2]/div/div[2]/div/div/div[3]/div/div[2]/div/form/table/tbody/tr[1]/td[12]/span').scrollLeft += 250",
            "");

    //Get page title in selenium webdriver
    String actual = driver.getTitle();

}

From source file:com.mycompany.selenium.factory.tests.Init.java

public static WebDriver getDriver() {
    if (null == driver) {
        driver = new FirefoxDriver();
        driver.get("http://yandex.ru");
    }//from  w w  w .  j  av a  2  s.c  o m
    return driver;
}

From source file:com.mycompany.seliniumtest.Selenium2Example.java

public static void main(String[] args) {
    System.setProperty("webdriver.gecko.driver", "/usr/local/Cellar/geckodriver/geckodriver");

    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface,
    // not the implementation.

    //WebDriver driver = new FirefoxDriver();
    //WebDriver driver = new ChromeDriver();
    WebDriver driver = new FirefoxDriver();
    //WebDriver driver = new HtmlUnitDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();//from  w  w w .  j  a v  a2  s  .  c  om

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());

    // Google's search is rendered dynamically with JavaScript.
    // Wait for the page to load, timeout after 10 seconds
    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            return d.getTitle().toLowerCase().startsWith("cheese!");
        }
    });

    // Should see: "cheese! - Google Search"
    System.out.println("Page title is: " + driver.getTitle());

    //Close the browser
    driver.quit();
}

From source file:com.nosoftskills.travianbot.DumpPlayers.java

License:Apache License

public static void main(String[] args) throws IOException {
    System.setProperty("webdriver.gecko.driver", "/usr/bin/firefox");
    WebDriver driver = new FirefoxDriver();
    Settings settings = Settings.load();
    Login loginPage = new Login(driver, settings.getRootUrl());
    loginPage.load();/*w w w . j a  v a 2s . c  o m*/
    loginPage.login(settings.getUserName(), settings.getPassword());

    AlliancePlayers alliancePlayersPage = new AlliancePlayers(driver, settings.getRootUrl());
    alliancePlayersPage.load();
    alliancePlayersPage.getPlayers().forEach(System.out::println);
}

From source file:com.nosoftskills.travianbot.Main.java

License:Apache License

public static void main(String[] args) throws Exception {
    Settings settings = Settings.load();

    System.setProperty("webdriver.gecko.driver", settings.getBrowserLocation());
    WebDriver driver = new FirefoxDriver();

    while (true) {
        Login loginPage = new Login(driver, settings.getRootUrl());
        loginPage.load();// w w w  .j  a v a2 s. c  om
        loginPage.login(settings.getUserName(), settings.getPassword());

        //            Home homePage = new Home(driver, settings.getRootUrl());
        //            homePage.load();
        //            List<IncomingAttack> currentIncomingAttacks = homePage.getIncomingAttacks();
        //            currentIncomingAttacks.forEach(Main::alertForIncomingAttack);
        //            previousIncomingAttacks.clear();
        //            currentIncomingAttacks.forEach(attack -> previousIncomingAttacks.put(attack.getVillageName(), attack.getNumberOfAttacks()));

        try {
            FarmList farmListPage = new FarmList(driver, settings.getRootUrl());
            settings.getLists().forEach(list -> raidList(farmListPage, list));

            int sleepTime = MINIMUM_SECONDS + random.nextInt(MAXIMUM_SECONDS - MINIMUM_SECONDS);
            System.out.println(ZonedDateTime.now().format(formatter) + ": Sent raids. Sleeping for " + sleepTime
                    + " seconds");
            Thread.sleep(sleepTime * 1000);
        } catch (IllegalStateException ise) {
            System.out.println(ise.getMessage());
            Thread.sleep(60 * 1000);
        }
    }
}

From source file:com.novartis.opensource.yada.test.YADAAdminTest.java

License:Apache License

/**
 * Configure test for provided browser/* w  ww .jav a 2s .co  m*/
 * 
 * @param browser the currently tested client
 * @param properties the name of the properties file
 * @throws IOException  when properties can't be loaded
 */
@Parameters({ "browser", "properties" })
@BeforeClass
public void init(String browser, String properties) throws IOException {
    ConnectionFactoryTest.setProps(properties);
    Properties props = ConnectionFactoryTest.getProps();
    this.host = props.getProperty("YADA.host");
    this.dbDriver = props.getProperty("YADA.index.driverClassName");
    this.dbUrl = props.getProperty("YADA.index.url");
    this.dbUser = props.getProperty("YADA.index.username");
    this.dbPw = props.getProperty("YADA.index.password");
    this.dbValidationQuery = props.getProperty("YADA.index.validationQuery");
    if (browser.equalsIgnoreCase("firefox")) {
        setDriver(new FirefoxDriver());
    } else if (browser.equalsIgnoreCase("chrome")) {
        setDriver(new ChromeDriver());
    }
    getDriver().get(PROTOCOL + this.host + this.uri);
}

From source file:com.openones.auto.selen.Sample01.java

License:Apache License

public static void main(String[] args) {
    // Create a new instance of the Firefox driver
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation.
    WebDriver driver = new FirefoxDriver();
    //WebDriver driver = new InternetExplorerDriver();

    // And now use this to visit Google
    driver.get("http://www.google.com");
    // Alternatively the same thing can be done like this
    // driver.navigate().to("http://www.google.com");

    // Find the text input element by its name
    WebElement element = driver.findElement(By.name("q"));

    // Enter something to search for
    element.sendKeys("Cheese!");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();//  ww w. j  a  v a  2s  .  co  m

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());

    // Google's search is rendered dynamically with JavaScript.
    // Wait for the page to load, timeout after 10 seconds
    (new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            return d.getTitle().toLowerCase().startsWith("cheese!");
        }
    });

    // Should see: "cheese! - Google Search"
    System.out.println("Page title is: " + driver.getTitle());

    //Close the browser
    driver.quit();
}

From source file:com.osbitools.ws.shared.xui.GenericGuiWebTest.java

License:LGPL

@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}

From source file:com.photon.phresco.Screens.InvalidJarBase.java

public void instantiateBrowser(String selectedBrowser, String selectedPlatform, String applicationURL,
        String applicationContext) throws ScreenException, MalformedURLException {

    if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_CHROME)) {
        try {/*from   w  w  w  .j a va2 s . com*/
            // "D:/Selenium-jar/chromedriver_win_19.0.1068.0/chromedriver.exe"
            chromeService = new ChromeDriverService.Builder()
                    .usingDriverExecutable(new File(getChromeLocation())).usingAnyFreePort().build();

            log.info("-------------***LAUNCHING GOOGLECHROME***--------------");

            driver = new ChromeDriver(chromeService);
            //driver.manage().window().maximize();
            //   driver = new ChromeDriver(chromeService, chromeOption);
            // driver.manage().timeouts().implicitlyWait(30,
            // TimeUnit.SECONDS);            
            //driver.navigate().to(applicationURL + applicationContext);
            driver.manage().window().maximize();
            driver.navigate().to(applicationURL + applicationContext);

        } catch (Exception e) {
            e.printStackTrace();
        }

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_IE)) {
        log.info("---------------***LAUNCHING INTERNET EXPLORE***-----------");
        driver = new InternetExplorerDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_FIREFOX)) {
        log.info("-------------***LAUNCHING FIREFOX***--------------");
        driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.navigate().to(applicationURL + applicationContext);

    } else if (selectedBrowser.equalsIgnoreCase(Constants.BROWSER_OPERA)) {
        log.info("-------------***LAUNCHING OPERA***--------------");
        System.out.println("******entering window maximize********");
        try {
            System.out.println("******entering window maximize********");
            Robot robot;
            try {
                robot = new Robot();
                robot.keyPress(KeyEvent.VK_ALT);
                robot.keyPress(KeyEvent.VK_SPACE);
                robot.keyRelease(KeyEvent.VK_ALT);
                robot.keyRelease(KeyEvent.VK_SPACE);
                robot.keyPress(KeyEvent.VK_X);
                robot.keyRelease(KeyEvent.VK_X);
            } catch (AWTException e) {

                e.printStackTrace();
            }

        } catch (Exception e) {

            e.printStackTrace();
        }

    } else {
        throw new ScreenException("------Only FireFox,InternetExplore and Chrome works-----------");
    }

}

From source file:com.pineapple.eckotur.web.test.DeleteOffer.java

@BeforeClass
public static void setUp() throws Exception {
    driver = new FirefoxDriver();
    // se define el url base del proyecto web
    baseUrl = "http://localhost:8080/Eckotur.service/cart.html";
    /* Indica cuanto se espera para la respuesta de cualquier comando realizado hacia el navegador*/
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}