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

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

Introduction

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

Prototype

@Override
    public WebElement findElementByXPath(String using) 

Source Link

Usage

From source file:org.ado.picasa.Main.java

License:Apache License

private static List<String> getVideoUrls(FirefoxDriver driver, List<String> videoHrefLinks, String returnPage) {
    final List<String> urls = new ArrayList<>();
    for (String href : videoHrefLinks) {
        System.out.println(String.format("downloading video: %s", href));
        try {/* ww  w  .  ja  va2 s . c  o  m*/
            driver.navigate().to(href);
            TimeUnit.SECONDS.sleep(1);

            driver.switchTo().frame(driver.findElementByXPath("//iframe[@class='scaledimage-onscreenpane']"));
            urls.add(driver.findElementByXPath("//video").getAttribute("src"));

        } catch (Exception e) {
            System.err.println(String.format("Cannot get video url from '%s'. Skipping ...", href));
            e.printStackTrace();
        } finally {
            driver.navigate().to(returnPage);
        }
    }
    return urls;
}