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.nativetests.NativeChildElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindChildButtonsIdentifiedByPartialText() throws Exception {
    openStartActivity();//ww  w  .ja  va2  s. c  o  m
    WebElement rootElement = driver.findElement(By.id("l10n"));
    String buttonText = "EN Butto";
    List<WebElement> elements = rootElement.findElements(By.partialLinkText(buttonText));
    Assert.assertEquals(elements.size(), 1);
    Assert.assertTrue(elements.get(0).getText().contains(buttonText));
}

From source file:org.openqa.selendroid.nativetests.NativeChildElementFindingTest.java

License:Apache License

@Test()
public void testShouldNotBeAbleToLocateASingleChildElementByPartialTextThatDoesNotExist() {
    openStartActivity();//ww w.j  ava  2  s. co  m
    WebElement rootElement = driver.findElement(By.id("l10n"));
    try {
        rootElement.findElement(By.partialLinkText("nonExistantButton"));
        Assert.fail("Should not have succeeded");
    } catch (NoSuchElementException e) {
        // this is expected
    }
}

From source file:org.openqa.selendroid.nativetests.NativeChildElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindChildButtonIdentifiedByPartialText() throws Exception {
    openStartActivity();/*from  w  ww  .java  2s .c  o m*/
    WebElement rootElement = driver.findElement(By.id("l10n"));
    String buttonText = "EN Butto";
    WebElement clickMe = rootElement.findElement(By.partialLinkText(buttonText));
    Assert.assertTrue(clickMe.getText().contains(buttonText));
}

From source file:org.openqa.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindButtonIdentifiedByPartialText() throws Exception {
    openStartActivity();//from   w w  w.jav  a 2  s . c o  m
    String buttonText = "EN Butto";
    WebElement clickMe = driver.findElement(By.partialLinkText(buttonText));
    Assert.assertTrue(clickMe.getText().contains(buttonText));
}

From source file:org.openqa.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test
public void testShouldBeAbleToFindButtonsIdentifiedByPartialText() throws Exception {
    openStartActivity();//from  w  w w  . j a va2  s .c o  m
    String buttonText = "EN Butto";
    List<WebElement> elements = driver.findElements(By.partialLinkText(buttonText));
    Assert.assertEquals(elements.size(), 1);
    Assert.assertTrue(elements.get(0).getText().contains(buttonText));
}

From source file:org.openqa.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test()
public void testShouldNotBeAbleToLocateASingleElementByPartialTextThatDoesNotExist() {
    openStartActivity();//from   w w  w.j a  v a 2 s.  co m
    try {
        driver.findElement(By.partialLinkText("nonExistentButton"));
        Assert.fail("Should not have succeeded");
    } catch (NoSuchElementException e) {
        // this is expected
    }
}

From source file:org.openqa.selendroid.nativetests.NativeElementFindingTest.java

License:Apache License

@Test()
public void testShouldNotBeAbleToLocateMultipleElementsByPartialTextThatDoesNotExist() {
    openStartActivity();//from  w  w  w.ja  v  a2 s  .  c  om
    assertListIsEmpty(driver.findElements(By.partialLinkText("nonExistentButton")));
}

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

License:Apache License

@Test
public void testShouldNotBeAbleToLocateASingleElementByPartialTextThatDoesNotExist() {
    openWebdriverTestPage(HtmlTestData.FORM_PAGE);
    WebElement rootElement = driver.findElement(By.id("multi"));
    try {//  w  w w  . ja v  a  2 s  .co  m
        rootElement.findElement(By.partialLinkText("notThere"));
        Assert.fail("Should not have succeeded");
    } catch (NoSuchElementException e) {
        // this is expected
    }
}

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

License:Apache License

@Test
public void testShouldNotBeAbleToLocateMultipleElementsByPartialTextThatDoesNotExist() {
    openWebdriverTestPage(HtmlTestData.FORM_PAGE);
    WebElement rootElement = driver.findElement(By.id("multi"));
    assertListIsEmpty(rootElement.findElements(By.partialLinkText("notThere")));
}

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

License:Apache License

@Test
public void testShouldBeAbleToFindElementAndClickOnLinkIdentifiedByPartialText() throws Exception {
    openWebdriverTestPage(HtmlTestData.XHTML_TEST_PAGE);
    WebElement rootElement = driver.findElement(By.className("content"));
    WebElement clickMe = rootElement.findElement(By.partialLinkText("click m"));
    clickMe.click();//from www. j  a  v a 2  s  . c  o m

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