Example usage for org.openqa.selenium WebDriver getCurrentUrl

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

Introduction

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

Prototype

String getCurrentUrl();

Source Link

Document

Get a string representing the current URL that the browser is looking at.

Usage

From source file:com.citrix.g2w.webdriver.pages.SettingsPage.java

License:Open Source License

/**
 * Constructor to initialize instance variables and verify if we are on the
 * Settings page.//from   w w  w.j  a v a 2s  . c  o m
 * 
 * @param webDriver
 *            (web driver)
 */
public SettingsPage(final WebDriver webDriver) {
    this.driver = webDriver;
    Assert.assertTrue(webDriver.getCurrentUrl().contains("settings.tmpl"));
    PageFactory.initElements(this.driver, this);
}

From source file:com.citrix.g2w.webdriver.pages.survey.AnswerSurveyQuestionPage.java

License:Open Source License

/**
 * Constructor to initialize instance variables and verify if we are on the
 * Survey test Page.//  www.  j  ava  2 s .c om
 * 
 * @param SurveyTestUrl
 *            (Survey test URL)
 * @param webDriver
 *            (web driver)
 */
public AnswerSurveyQuestionPage(final String surveyTestUrl, final WebDriver webDriver) {
    this.driver = webDriver;
    this.driver.get(surveyTestUrl);
    Assert.assertTrue(webDriver.getCurrentUrl().contains("/survey/"));
    PageFactory.initElements(this.driver, this);
}

From source file:com.citrix.g2w.webdriver.pages.survey.SurveyAnswerSubmittedPage.java

License:Open Source License

/**
 * Constructor to initialize instance variables and verify if we are on the
 * Survey test Page./*  ww w.  j a  v a2  s  . c o m*/
 * 
 * @param webDriver
 *            (web driver)
 */
public SurveyAnswerSubmittedPage(final WebDriver webDriver) {
    this.driver = webDriver;
    Assert.assertTrue(webDriver.getCurrentUrl().contains("/survey/submitted.tmpl"));
    PageFactory.initElements(this.driver, this);
}

From source file:com.citrix.g2w.webdriver.pages.SystemStatusPage.java

License:Open Source License

/**
 * Constructor to initialize instance variables and verify if we are on the
 * correct page./*from w w w .j  a  v  a2 s .co m*/
 * @param webDriver
 *            (web driver)
 * @param testG2wHost
 *            (test G2w host)
 */
public SystemStatusPage(final WebDriver webDriver, final String testG2wHost) {
    String url = "https://" + testG2wHost + "/system-status";
    webDriver.get(url);
    Assert.assertTrue(webDriver.getCurrentUrl().contains("/system-status"));
    this.logger.logWithScreenShot("After opening system-status page having url :" + url, webDriver);
}

From source file:com.cloudbees.test.SeleniumTest.java

License:Apache License

private void testSeleniumDriver(WebDriver webDriver) {
    System.err.println("");
    System.err.println("#############################");
    System.err.println("# TEST WITH " + webDriver);
    System.err.println("#############################");
    try {/* w w w.  jav  a2  s  .c o m*/
        String url = "https://google.com";
        webDriver.get(url);
        Assert.assertEquals("Unexpected page title requesting " + url + " with selenium driver "
                + webDriver.toString() + " displaying " + webDriver.getCurrentUrl(), "Google",
                webDriver.getTitle());
        System.err.println("SUCCESSFULLY invoked Selenium driver" + webDriver.toString() + " with URL "
                + webDriver.getCurrentUrl() + ", page.title='" + webDriver.getTitle() + "'");
    } finally {
        webDriver.close();
        webDriver.quit();
    }
}

From source file:com.cognifide.qa.bb.scope.frame.type.AemContentFrame.java

License:Apache License

/**
 * Switches to cq-cf-frame, if the address of the page contains "/cf#".
 *//*from  w  w  w  .j  a va 2 s  .  c o  m*/
@Override
public void switchTo(WebDriver webDriver, BobcatWait bobcatWait) {
    if (webDriver.getCurrentUrl().contains(CF_URL_PART)) {
        LOG.debug("switching to AEM content frame..");
        bobcatWait.withTimeout(Timeouts.MEDIUM)
                .until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(AEM_CF_FRAME));
        LOG.debug("..switched");
    } else {
        LOG.info("current URL does not contain '{}' fragment", CF_URL_PART);
    }
}

From source file:com.comcast.magicwand.drivers.AbstractPhoenixDriver.java

License:Apache License

/**
 * {@inheritDoc}//w  w  w  .  ja v a 2  s.  co  m
 */
public String getCurrentUrl() {
    WebDriver driver = this.getDriver();
    String currentUrl = null;

    if (null != driver) {
        currentUrl = driver.getCurrentUrl();
    }

    return currentUrl;
}

From source file:com.common.ExpectedConditions.java

License:Apache License

/**
 * An expectation for the URL of the current page to be a specific url.
 *
 * @param url the url that the page should be on
 * @return <code>true</code> when the URL is what it should be
 *//*from   www.ja  va2s .  co m*/
public static ExpectedCondition<Boolean> urlToBe(final String url) {
    return new ExpectedCondition<Boolean>() {
        private String currentUrl = "";

        @Override
        public Boolean apply(WebDriver driver) {
            currentUrl = driver.getCurrentUrl();
            return currentUrl != null && currentUrl.equals(url);
        }

        @Override
        public String toString() {
            return String.format("url to be \"%s\". Current url: \"%s\"", url, currentUrl);
        }
    };
}

From source file:com.common.ExpectedConditions.java

License:Apache License

/**
 * An expectation for the URL of the current page to contain specific text.
 *
 * @param fraction the fraction of the url that the page should be on
 * @return <code>true</code> when the URL contains the text
 */// w  w  w .  ja  v a2s  .c  o m
public static ExpectedCondition<Boolean> urlContains(final String fraction) {
    return new ExpectedCondition<Boolean>() {
        private String currentUrl = "";

        @Override
        public Boolean apply(WebDriver driver) {
            currentUrl = driver.getCurrentUrl();
            return currentUrl != null && currentUrl.contains(fraction);
        }

        @Override
        public String toString() {
            return String.format("url to contain \"%s\". Current url: \"%s\"", fraction, currentUrl);
        }
    };
}

From source file:com.common.ExpectedConditions.java

License:Apache License

/**
 * Expectation for the URL to match a specific regular expression
 *
 * @param regex the regular expression that the URL should match
 * @return <code>true</code> if the URL matches the specified regular expression
 *///from ww w .  j  av a  2s .  c  o m
public static ExpectedCondition<Boolean> urlMatches(final String regex) {
    return new ExpectedCondition<Boolean>() {
        private String currentUrl;
        private Pattern pattern;
        private Matcher matcher;

        @Override
        public Boolean apply(WebDriver driver) {
            currentUrl = driver.getCurrentUrl();
            pattern = Pattern.compile(regex);
            matcher = pattern.matcher(currentUrl);
            return matcher.find();
        }

        @Override
        public String toString() {
            return String.format("url to match the regex \"%s\". Current url: \"%s\"", regex, currentUrl);
        }
    };
}