Example usage for org.openqa.selenium WebDriver manage

List of usage examples for org.openqa.selenium WebDriver manage

Introduction

In this page you can find the example usage for org.openqa.selenium WebDriver manage.

Prototype

Options manage();

Source Link

Document

Gets the Option interface

Usage

From source file:com.hotwire.selenium.desktop.us.partners.CarPartnerPageProvider.java

License:Open Source License

public static CarPartnersPage get(WebDriver webDriver) {

    // Wait while inner content will be loaded
    webDriver.manage().timeouts().pageLoadTimeout(PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS);

    String url = webDriver.getCurrentUrl();
    LOGGER.info("PARTNER URL: " + url);

    if (checkUrl(url, "http://www.bookingbuddy.com")) {
        return new CarBookingBuddyPage(webDriver);
    }/*from w  w w  .j  a v a2 s.c  om*/
    if (checkUrl(url, "http://www.kayak.com")) {
        return new CarKayakPage(webDriver);
    }
    if (checkUrl(url, "http://www.carrentals.com")) {
        return new CarRentalsPage(webDriver);
    }
    if (checkUrl(url, "http://www.expedia.com")) {
        return new CarExpediaPage(webDriver);
    }
    if (checkUrl(url, "http://www.orbitz.com")) {
        return new CarOrbitzPage(webDriver);
    }

    throw new RuntimeException("Partner's page wasn't resolved");
}

From source file:com.hotwire.selenium.desktop.us.partners.HotelPartnerPageDetector.java

License:Open Source License

public static NAME detect(WebDriver webDriver) {

    // Wait while inner content will be loaded
    webDriver.manage().timeouts().pageLoadTimeout(PAGE_LOAD_TIMEOUT, TimeUnit.SECONDS);

    String url = webDriver.getCurrentUrl();
    LOGGER.info("PARTNER URL: " + url);

    for (NAME name : NAME.values()) {
        if (url.contains(name.pageName.toLowerCase())) {
            return name;
        }/*from  w ww  . j  a  va2s .c  o  m*/
    }
    throw new RuntimeException("Could not recognize the url " + url);
}

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 ww  w  .jav  a2  s  . c  om
        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.watson.app.qaclassifier.selenium.CommonFunctions.java

License:Open Source License

public static boolean isMobileUI(WebDriver driver) {
    return driver.manage().window().getSize().getWidth() <= 767;
}

From source file:com.ibm.watson.app.qaclassifier.selenium.CommonFunctions.java

License:Open Source License

public static boolean isTabletUI(WebDriver driver) {
    int width = driver.manage().window().getSize().getWidth();
    return width > 767 && width <= 1199;
}

From source file:com.ibm.watson.app.qaclassifier.selenium.drivers.Device.java

License:Open Source License

private static void doResize(WebDriver driver, int width, int height) {
    // We have run into issues where the resize command intermittently fails.
    try {//ww w  .j a va2 s.c  o  m
        driver.manage().window().setSize(new Dimension(width, height));
    } catch (WebDriverException e) {
        e.printStackTrace();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {
        }
        driver.manage().window().setSize(new Dimension(width, height));
    }
}

From source file:com.ibm.watson.app.qaclassifier.selenium.drivers.Device.java

License:Open Source License

private static void doMaximize(WebDriver driver) {
    // We have run into issues where the resize command intermittently fails.
    try {/*  ww  w.ja  v  a  2  s  . c o m*/
        driver.manage().window().maximize();
    } catch (WebDriverException e) {
        e.printStackTrace();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {
        }
        driver.manage().window().maximize();
    }
}

From source file:com.ibm.watson.app.qaclassifier.selenium.drivers.SeleniumTestRunner.java

License:Open Source License

private WebDriver getDriver(Environment env, Device device, Browser browser) throws Exception {
    WebDriver driver = browser.getDriver(env);
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    // Add a small delay to prevent timing issues in the browser
    EventFiringWebDriver driverWithEvents = new EventFiringWebDriver(driver);
    driverWithEvents.register(new WebDriverDelay());

    device.configure(driverWithEvents);/*from  w ww . ja va2  s . c om*/
    return driverWithEvents;
}

From source file:com.ibm.watson.movieapp.dialog.fvt.config.Driver.java

License:Open Source License

/**
 * getInstance() /*  w  ww.j av  a  2s  .  c  o m*/
 * @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.java.AppTestType_18_11_2015.java

public void SUBMITTEDASSET(WebDriver driver, String fieldText, String value) {

    try {//from   ww  w.j  av  a2  s.  com

        ELISTINGS(driver);

        driver.get(value);
        driver.manage().deleteAllCookies();
        driver.findElement(By.id("aurid")).sendKeys("mglaz@assetnation.com");

        driver.findElement(By.id("apwd")).sendKeys("Equipment1$");
        driver.findElement(By.xpath("//input[@value='Login']")).click();

        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

        driver.findElement(By.id("userAgreementBtn")).click();

        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.findElement(By.linkText("Imports")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElement(By.linkText("SelfService")).click();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        String assettitle = driver.findElement(By.xpath("//td[4]")).getText();

        if (Listingtitle.equalsIgnoreCase(assettitle)) {

            AssetID = driver.findElement(By.xpath("//td[2]/a")).getText();

            System.out.println(AssetID);

            resultDetails.setFlag(true);
        }

    } catch (Exception e) {

        resultDetails.setFlag(false);
    }

}