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:loteriaNacional.RobotLoteria.java

public RobotLoteria() {
    this.driver = new FirefoxDriver();
    this.url = "http://www.loteriasyapuestas.es/es/loteria-nacional";
    driver.get(url);//from  w  ww  .jav a 2 s .c  o m
}

From source file:loteriaNacional.RobotLoteriaJS.java

RobotLoteriaJS() {
    driver = (WebDriver) new FirefoxDriver();
    js = (JavascriptExecutor) driver;// w  w w  .  j ava2s  .co  m

    this.url = "http://www.loteriasyapuestas.es/es/loteria-nacional";
    driver.get(url);
}

From source file:marmotinni.MarmotinniRunner.java

License:Apache License

public static void main(String[] args) {
    ArrayList<String> scripts = new ArrayList<String>();
    Map<String, String> argsMap = new HashMap<String, String>();
    for (String arg : args) {
        String[] keyValuePair = arg.split("=");
        if (keyValuePair[0].equals("script"))
            scripts.add(keyValuePair[1]);
        else//from www .java2  s  .  c  o m
            argsMap.put(keyValuePair[0], keyValuePair[1]);
    }
    final String showScriptsArg = argsMap.get("showScripts");
    TestStep.showScripts = showScriptsArg != null && showScriptsArg.equalsIgnoreCase("true");
    final String showStepsArg = argsMap.get("showSteps");
    TestCase.showSteps = showStepsArg != null && showStepsArg.equalsIgnoreCase("true");

    final String url = argsMap.get("url");
    System.out.println(url);

    final String browser = argsMap.get("browser");
    WebDriver driver;
    if (browser != null && browser.equalsIgnoreCase("chrome"))
        driver = new ChromeDriver();
    else
        driver = new FirefoxDriver();

    driver.get(url);

    int exitCode = 0;
    try {
        MarmotinniRunner mr = new MarmotinniRunner();
        final String verboseXMLParsingArg = argsMap.get("verboseXMLParsing");
        mr.verboseXMLParsing = verboseXMLParsingArg != null && verboseXMLParsingArg.equalsIgnoreCase("true");
        int n = scripts.size();
        for (int i = 0; i < n; i++) {
            if (!mr.runTest(driver, scripts.get(i))) {
                System.out.println("script failed");
                exitCode = 1;
            }
        }
    } catch (Exception e) {
        System.out.println(e.getMessage());
        exitCode = 1;
    } finally {
        driver.quit();
    }
    System.exit(exitCode);
}

From source file:melihovv.AvitoNewMessageChecker.AvitoNewMessageChecker.java

License:Open Source License

public static void main(String[] args) {
    final Logger log = LogManager.getLogger(AvitoNewMessageChecker.class.getName());

    if (args.length != 1) {
        log.fatal("?    config.yaml");
    }//from w  w w.j  ava 2s . c o  m

    YamlReader reader = null;
    try {
        reader = new YamlReader(new FileReader(args[0]));
    } catch (FileNotFoundException e) {
        log.fatal("?   config.yaml");
        log.fatal(e.getMessage());
        System.exit(1);
    }

    Map config = null;
    try {
        Object temp = reader.read();
        config = (Map) temp;
    } catch (YamlException e) {
        log.fatal("  ??? config.yaml");
        log.fatal(e.getMessage());
        System.exit(1);
    }

    final List<String> keys = Arrays.asList("avito_login", "avito_pass", "smtp_host", "smtp_port", "smtp_login",
            "smtp_pass", "email_from", "email_to");

    for (final String key : keys) {
        if (!config.containsKey(key)) {
            String values = String.join(", ", keys);
            log.fatal("-    : " + values);
            System.exit(1);
        }
    }

    try {
        final WebDriver driver = new FirefoxDriver();
        final String baseUrl = "https://www.avito.ru/";
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.get(baseUrl + "profile/login");
        driver.findElement(By.name("login")).clear();
        driver.findElement(By.name("login")).sendKeys(config.get("avito_login").toString());
        driver.findElement(By.name("password")).clear();
        driver.findElement(By.name("password")).sendKeys(config.get("avito_pass").toString());
        driver.findElement(By.xpath("//button[@type='submit']")).click();
        driver.findElement(By.cssSelector("#sidebar-nav-messenger > " + "a.link.js-sidebar-menu-link")).click();

        final boolean newMessagesPresent = isElementPresent(driver, By.className("is-design-new"));
        driver.get(baseUrl + "profile/exit");
        driver.quit();

        if (newMessagesPresent) {
            log.info("?  ??");
            sendNotification(config.get("smtp_host").toString(), config.get("smtp_port").toString(),
                    config.get("smtp_login").toString(), config.get("smtp_pass").toString(),
                    config.get("email_from").toString(), config.get("email_to").toString(),
                    "New message on avito.ru", "You have unread messages on avito.ru");
        } else {
            log.info("? ? ");
        }
    } catch (Exception e) {
        log.error("-   ");
        log.error(e.getMessage());
        log.error(Arrays.toString(e.getStackTrace()));
        System.exit(1);
    }
}

From source file:name.gluino.webmailfeed.InjectIntoWebmailAddressBook.java

License:Open Source License

/**
 * Constructor/*from  w  w  w . ja v  a 2  s .com*/
 */

public InjectIntoWebmailAddressBook(PropertiesReader config, Set<ClubMember> allMembers) {
    checkNotNull(config, "config");
    checkNotNull(allMembers, "allMembers");
    this.config = config;
    this.allMembers = Collections.unmodifiableSet(allMembers);
    this.driver = new FirefoxDriver();
    this.driver.manage().timeouts().implicitlyWait(DOG_SLOW_SECONDS, TimeUnit.SECONDS);
}

From source file:nestnz.org.ContactPageTestSuites.java

@Test
public void LaunchTestOnFireFox() throws Exception {
    System.setProperty("webdriver.gecko.driver", ".\\Browsers\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    testContactPageTestSuites();/* w  w  w.j a  v  a2 s.  c  o  m*/
}

From source file:nestnz.org.StatisticPageTestSuites.java

@Test
public void LaunchTestOnFireFox() throws Exception {
    System.setProperty("webdriver.gecko.driver", ".\\Browsers\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    testStatisticPageTestSuites();//from  w ww .ja  va 2 s .  co  m
}

From source file:net.atf4j.webdriver.BrowserFactory.java

License:Open Source License

/**
 * Local webDriver INSTANCE.//from   www .  j  ava  2 s .  c o m
 *
 * @param targetBrowser the target browser
 * @return the webDriver
 */
protected static WebDriver localWebDriver(final String targetBrowser) {
    WebDriver webDriver = null;

    switch (targetBrowser.toLowerCase()) {
    case "chrome":
        webDriver = new ChromeDriver();
        break;
    case "ff":
    case "firefox":
        webDriver = new FirefoxDriver();
        break;
    case "ie":
    case "internetexplorer":
        webDriver = new InternetExplorerDriver();
        break;
    case "edge":
        webDriver = new EdgeDriver();
        break;
    case "opera":
        webDriver = new OperaDriver();
        break;
    case "safari":
        System.setProperty("webdriver.safari.noinstall", "true");
        webDriver = new SafariDriver();
        break;
    // case "htmlunit":
    // webDriver = new HtmlUnitDriver();
    // break;
    // case "phantomjs":
    // case "headless":
    // default:
    // final DesiredCapabilities desiredCapabilities = new
    // DesiredCapabilities();
    // desiredCapabilities.setJavascriptEnabled(true);
    // desiredCapabilities.setCapability(
    // PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
    // "../web-driver-bin/phantomjs.exe");
    // webDriver = new PhantomJSDriver(desiredCapabilities);
    // break;
    }

    return webDriver;
}

From source file:net.mindengine.galen.browser.SeleniumBrowserFactory.java

License:Apache License

private Browser createLocalBrowser() {
    if (FIREFOX.equals(browserType)) {
        return new SeleniumBrowser(new FirefoxDriver());
    } else if (CHROME.equals(browserType)) {
        return new SeleniumBrowser(new ChromeDriver());
    } else if (IE.equals(browserType)) {
        return new SeleniumBrowser(new InternetExplorerDriver());
    } else if (PHANTOMJS.equals(browserType)) {
        return new SeleniumBrowser(new PhantomJSDriver());
    } else if (SAFARI.equals(browserType)) {
        return new SeleniumBrowser(new SafariDriver());
    } else/*from   w w  w  . j  ava2 s  . c o m*/
        throw new RuntimeException(String.format("Unknown browser type: \"%s\"", browserType));
}

From source file:net.mindengine.galen.tests.action.GalenPageActionInjectJavascriptTest.java

License:Apache License

@Test
public void shouldInject_javascript() throws IOException {
    WebDriver driver = new FirefoxDriver();
    Browser browser = new SeleniumBrowser(driver);
    browser.load(TEST_URL);//from   w w  w  .j  av a  2s .  c om

    GalenPageActionInjectJavascript action = new GalenPageActionInjectJavascript("/scripts/to-inject-1.js");
    action.execute(browser, new GalenPageTest(), null);

    WebElement element = driver.findElement(By.xpath("//body/injected-tag"));

    assertThat("Inject tags text should be", element.getText(), is("Some injected content"));
    browser.quit();
}