Example usage for org.openqa.selenium By partialLinkText

List of usage examples for org.openqa.selenium By partialLinkText

Introduction

In this page you can find the example usage for org.openqa.selenium By partialLinkText.

Prototype

public static By partialLinkText(String partialLinkText) 

Source Link

Usage

From source file:org.openqa.selendroid.webviewdrivertests.WebChildElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindElementsAndClickOnLinkIdentifiedByPartialText() throws Exception {
    openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE);
    WebElement rootElement = driver.findElement(By.className("content"));
    WebElement clickMe = rootElement.findElements(By.partialLinkText("click m")).get(0);
    clickMe.click();/*from w  w w.java  2s.com*/

    waitFor(pageTitleToBe(driver, "We Arrive Here"), 15, TimeUnit.SECONDS);
    Assert.assertEquals(driver.getTitle(), "We Arrive Here");
}

From source file:org.openqa.selendroid.webviewdrivertests.WebElementFindingTest.java

License:Apache License

@Test
public void testShouldNotBeAbleToLocateASingleElementByPartialTextThatDoesNotExist() {
    openWebdriverTestPage(HtmlTestData.FORM_PAGE);

    try {//  ww w .j a v a  2s .  c om
        driver.findElement(By.partialLinkText("notThere"));
        Assert.fail("Should not have succeeded");
    } catch (NoSuchElementException e) {
        // this is expected
    }
}

From source file:org.openqa.selendroid.webviewdrivertests.WebElementFindingTest.java

License:Apache License

@Test
public void testShouldNotBeAbleToLocateMultipleElementsByPartialTextThatDoesNotExist() {
    openWebdriverTestPage(HtmlTestData.FORM_PAGE);

    assertListIsEmpty(driver.findElements(By.partialLinkText("notThere")));
}

From source file:org.openqa.selendroid.webviewdrivertests.WebElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindElementAndClickOnLinkIdentifiedByPartialText() throws Exception {
    openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE);
    TestWaiter.waitForElement(By.partialLinkText("click"), 10, driver).click();

    waitFor(pageTitleToBe(driver, "We Arrive Here"), 15, TimeUnit.SECONDS);
    Assert.assertEquals(driver.getTitle(), "We Arrive Here");
}

From source file:org.openqa.selendroid.webviewdrivertests.WebElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindElementsAndClickOnLinkIdentifiedByPartialText() throws Exception {
    openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE);
    WebElement clickMe = driver.findElements(By.partialLinkText("click m")).get(0);
    clickMe.click();/*from   ww w.  ja  v a 2s  .  c  om*/

    waitFor(pageTitleToBe(driver, "We Arrive Here"), 15, TimeUnit.SECONDS);
    Assert.assertEquals(driver.getTitle(), "We Arrive Here");
}

From source file:org.ops4j.pax.shiro.itest.osgi.FacesBundleTest.java

License:Apache License

@Before
public void logOut() throws IOException, InterruptedException {
    // wait for server to come up
    Thread.sleep(2000);// w  w  w.  j av  a  2  s  . c o  m

    // Make sure we are logged out
    webDriver.get(getBaseUri());
    try {
        webDriver.findElement(By.partialLinkText("Log out")).click();
    } catch (NoSuchElementException e) {
        //Ignore
    }
}

From source file:org.ops4j.pax.shiro.itest.osgi.FacesBundleTest.java

License:Apache License

@Test
public void logIn() {

    webDriver.get(getBaseUri() + "login.jsf");
    webDriver.findElement(By.name("login:username")).sendKeys("root");
    webDriver.findElement(By.name("login:password")).sendKeys("secret");
    webDriver.findElement(By.name("login:submit")).click();

    // This'll throw an expection if not logged in
    webDriver.findElement(By.partialLinkText("Log out"));
}

From source file:org.ops4j.pax.shiro.itest.osgi.FacesBundleTest.java

License:Apache License

@Test
public void shouldRememberMeOnClientRestart() throws Exception {

    webDriver.get(getBaseUri() + "login.jsf");
    webDriver.findElement(By.name("login:username")).sendKeys("root");
    webDriver.findElement(By.name("login:password")).sendKeys("secret");
    webDriver.findElement(By.name("login:rememberMe")).click();
    webDriver.findElement(By.name("login:submit")).click();

    Cookie cookie = webDriver.manage().getCookieNamed("rememberMe");
    webDriver.close();//from w  w w  .  ja va 2  s  .co m

    webDriver = new HtmlUnitDriver();
    webDriver.get(getBaseUri());
    webDriver.manage().addCookie(cookie);

    webDriver.get(getBaseUri());
    webDriver.findElement(By.partialLinkText("Log out"));

    webDriver.findElement(By.partialLinkText("account")).click();

    // login page should be shown again - user remembered but not authenticated
    webDriver.findElement(By.name("login:username"));
}

From source file:org.ops4j.pax.shiro.itest.osgi.FacesBundleTest.java

License:Apache License

@Test
@Ignore("missing JSF support in Pax Web")
public void shouldNotRememberMeWithoutCookie() throws Exception {

    webDriver.get(getBaseUri() + "login.jsf");
    webDriver.findElement(By.name("login:username")).sendKeys("root");
    webDriver.findElement(By.name("login:password")).sendKeys("secret");
    webDriver.findElement(By.name("login:rememberMe")).click();
    webDriver.findElement(By.name("login:submit")).click();

    Cookie cookie = webDriver.manage().getCookieNamed("rememberMe");
    assertThat(cookie, is(notNullValue()));
    webDriver.close();//from www .j  ava 2 s. co  m

    webDriver = new HtmlUnitDriver();
    webDriver.get(getBaseUri());

    // fails since tags get rendered verbatim, so we do see the
    // content that should be hidden
    thrown.expect(NoSuchElementException.class);
    webDriver.findElement(By.partialLinkText("Log out"));
}

From source file:org.ops4j.pax.shiro.itest.osgi.Jetty9FacesBundleTest.java

License:Apache License

@Before
public void logOut() throws IOException, InterruptedException {
    // wait for server to come up
    Thread.sleep(2000);/*from w w w . ja  v  a2 s.  c o  m*/

    // Make sure we are logged out
    webDriver.get(getBaseUri());
    try {
        webDriver.findElement(By.partialLinkText("Log out")).click();
    } catch (NoSuchElementException e) {
        // Ignore
    }
}