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:co.edu.uniandes.csw.SportGroup.web.test.SportClubIT.java

@Test
@RunAsClient//from  www . j  a  v a 2s  .c  o  m
public void t3deleteSport() throws Exception {
    boolean success = false;
    driver.findElement(By.partialLinkText("Sport")).click();
    Thread.sleep(3000);
    List<WebElement> rows = driver.findElements(By.xpath("//table[contains(@id,'recordList')]/tbody/tr"));
    for (WebElement webElement : rows) {
        List<WebElement> elems = webElement.findElements(By.xpath("td"));
        if (elems.get(0).getText().equals("Futbol") && elems.get(5).getText().equals("Colombia")) {
            List<WebElement> buttons = elems.get(6).findElements(By.xpath("button"));
            buttons.get(1).click();
            success = true;
            break;
        }
    }
    Thread.sleep(3000);
    //Se busca el objeto que fue eliminado, si se encuentra hay error al eliminar
    rows = driver.findElements(By.xpath("//table[contains(@id,'recordList')]/tbody/tr"));
    if (rows.size() > 0) {
        for (WebElement webElement : rows) {
            List<WebElement> elems = webElement.findElements(By.xpath("td"));
            if (elems.get(0).getText().equals("Futbol") && elems.get(5).getText().equals("Colombia")) {
                success = false;
                break;
            }
        }
    }

    Thread.sleep(1000);
    assertTrue(success);
}

From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java

License:Apache License

public By getFinderType(String identifier, String idValue) throws Exception {
    By findBy = null;//from  www .j  a v  a  2s.  c  o  m
    MobileWebIdentifyBy idType = null;
    try {
        idType = MobileWebIdentifyBy.valueOf(identifier.toUpperCase());
    } catch (Throwable e) {
        throwUnsupportedIndentifierException(this.getName(), "getFinderType", identifier);
    }
    switch (identifier.toUpperCase()) {
    case "ID":
        findBy = By.id(idValue);
        break;
    case "NAME":
        findBy = By.name(idValue);
        break;
    case "CLASS":
        findBy = By.className(idValue);
        break;
    case "LINK_TEXT":
        findBy = By.linkText(idValue);
        break;
    case "PARTIAL_LINK_TEXT":
        findBy = By.partialLinkText(idValue);
        break;
    case "XPATH":
        findBy = By.xpath(idValue);
        break;
    case "CSS":
        findBy = By.cssSelector(idValue);
        break;
    case "TAG":
        findBy = By.tagName(idValue);
        break;
    }
    return findBy;
}

From source file:com.autocognite.selenium.lib.SeleniumWebUiDriver.java

License:Apache License

@SuppressWarnings("incomplete-switch")
public By getFinderType(String identifier, String idValue) throws Exception {
    By findBy = null;//w  w w  .  j  a  va 2  s .c o m
    WebIdentifyBy idType = null;
    try {
        idType = WebIdentifyBy.valueOf(identifier.toUpperCase());
    } catch (Throwable e) {
        throwUnsupportedIndentifierException(Configurator.getComponentName("WEBDRIVER_AUTOMATOR"),
                "getFinderType", identifier);
    }
    switch (idType) {
    case ID:
        findBy = By.id(idValue);
        break;
    case NAME:
        findBy = By.name(idValue);
        break;
    case CLASS:
        findBy = By.className(idValue);
        break;
    case LINK_TEXT:
        findBy = By.linkText(idValue);
        break;
    case PARTIAL_LINK_TEXT:
        findBy = By.partialLinkText(idValue);
        break;
    case XPATH:
        findBy = By.xpath(idValue);
        break;
    case CSS:
        findBy = By.cssSelector(idValue);
        break;
    case TAG:
        findBy = By.tagName(idValue);
        break;
    }
    return findBy;
}

From source file:com.axatrikx.webdriver.ElementHelper.java

License:Apache License

private By parseLocator(String locator) {
    String locValue;/*w  w w .j a  v a  2s  .com*/
    By byElement = null;
    if (locator.toLowerCase().startsWith("id=")) {
        locValue = locator.substring(3);
        byElement = By.id(locValue);
    } else if (locator.toLowerCase().startsWith("name=")) {
        locValue = locator.substring(5);
        byElement = By.name(locValue);
    } else if (locator.toLowerCase().startsWith("class=")) {
        locValue = locator.substring(6);
        byElement = By.className(locValue);
    } else if (locator.toLowerCase().startsWith("css=")) {
        locValue = locator.substring(4);
        byElement = By.cssSelector(locValue);
    } else if (locator.toLowerCase().startsWith("xpath=")) {
        locValue = locator.substring(6);
        byElement = By.xpath(locValue);
    } else if (locator.toLowerCase().startsWith("classname=")) {
        locValue = locator.substring(10);
        byElement = By.className(locValue);
    } else if (locator.toLowerCase().startsWith("tagname=")) {
        locValue = locator.substring(8);
        byElement = By.tagName(locValue);
    } else if (locator.toLowerCase().startsWith("link=")) {
        locValue = locator.substring(5);
        byElement = By.linkText(locValue);
    } else if (locator.toLowerCase().startsWith("partiallinktext=")) {
        locValue = locator.substring(16);
        byElement = By.partialLinkText(locValue);
    } else {
        // set default to id
        byElement = By.id(locator);
    }
    return byElement;
}

From source file:com.capgemini.scripts.Circuit.java

public void addCircuit() {

    BasicOperation.click(".//*[@id='menuForm:menuId']/div/div[2]/a[1]/img", webDriver);
    BasicOperation.waitFor(3000);/*from  w w  w .j ava2 s.c  om*/
    webDriver.findElement(By.partialLinkText("Circuit")).click();
    BasicOperation.waitFor(3000);
    BasicOperation.click("AddCircuit", webDriver);

    BasicOperation.fill("Short_Name", "Short_Name", webDriver);
    BasicOperation.fill("Long_Name", "Long_Name", webDriver);

    BasicOperation.clickCheckBox(".//*[@id='circuitSearchForm:owning']", "Owning", webDriver);
    BasicOperation.clickCheckBox(".//*[@id='circuitSearchForm:buying']", "Buying", webDriver);
    BasicOperation.clickCheckBox(".//*[@id='circuitSearchForm:legalEntity']", "Legal", webDriver);

    BasicOperation.clickCheckBox("ChkBox_Status", "Status", webDriver);

    BasicOperation.selectById("Dropdown_Status_change_reason", 4, webDriver);

    BasicOperation.selectById("Dropdown_Circuit_Category", 2, webDriver);
    BasicOperation.selectById("Dropdown_Circuit_Indicator", 1, webDriver);
    BasicOperation.selectById("Dropdown_Global_Circuit", 2, webDriver);

    BasicOperation.fill("Address", "Address", webDriver);
    // stepExecutor.enterTextValue("findElementByxpath",ResourceReader.readValue("Textbox_Address1"),
    // strDataFileName, "Address1", webDriver);

    if (DataMap.get("Territory").equalsIgnoreCase("Mexico")) {

        BasicOperation.fill(".//*[@id='circuitSearchForm:circuitAddressPanelRegion:0:externalNumberId']",
                ((int) (Math.random() * 10000)) + "", webDriver);

        BasicOperation.fill(".//*[@id='circuitSearchForm:circuitAddressPanelRegion:0:internalNumberId']",
                ((int) (Math.random() * 10000)) + "", webDriver);

    }

    BasicOperation.selectById(".//*[@id='circuitSearchForm:circuitAddressPanelRegion:0:stateMapId']", 1,
            webDriver);

    BasicOperation.fill("City", "City", webDriver);
    // stepExecutor.enterTextValue("findElementByxpath",ResourceReader.readValue("Textbox_City"),
    // strDataFileName, "City", webDriver);

    BasicOperation.selectById("Dropdown_Country", "Territory", webDriver);

    String code = DataMap.get("PostalCode");
    if (code.endsWith(".0")) {
        code = code.substring(0, code.length() - 2);
    }

    BasicOperation.fill("Textbox_PostalCode", code, webDriver);
    // BasicOperation.takeScreenShot();

    System.out.println("inside search");

    // BasicOperation.waitFor(2000);

    billing();
    contacts();
}

From source file:com.capgemini.scripts.Circuit.java

public void updateCircuit() {

    BasicOperation.click(".//*[@id='menuForm:menuId']/div/div[2]/a[1]/img", webDriver);
    BasicOperation.waitFor(3000);//  ww  w  .  j a v a 2s. c o  m
    webDriver.findElement(By.partialLinkText("Circuit")).click();

    BasicOperation.fill("Search Short Name", "Short_Name", webDriver);

    BasicOperation.click("Button_Search", webDriver);

    BasicOperation.waitFor(3000);

    BasicOperation.click("circuit_lookup", webDriver);

    // .//*[@id='circuitSearchForm:crtSearchResultDt']/tbody/tr/td/a

    BasicOperation.waitFor(3000);

    BasicOperation.fill("Change_Date", "Change_Date", webDriver);

    BasicOperation.waitFor(1500);

    BasicOperation.click("Button_Save", webDriver);

    BasicOperation.waitFor(7000);

}

From source file:com.dhenton9000.selenium.generic.GenericAutomationRepository.java

/**
 * generate the By selector//from  w  ww  .j ava2s. co  m
 *
 * @param selectorChoice the desired selector, eg by css Selector
 * @param selectorValue the string to search for
 * @return the By element
 */
public static By generateSelectorBy(SELECTOR_CHOICE selectorChoice, String selectorValue) {
    By selectorBy = null;

    switch (selectorChoice) {
    case id:
        selectorBy = By.id(selectorValue);
        break;
    case name:
        selectorBy = By.name(selectorValue);
        break;
    case className:
        selectorBy = By.className(selectorValue);
        break;
    case linkText:
        selectorBy = By.linkText(selectorValue);
        break;
    case xpath:
        selectorBy = By.xpath(selectorValue);
        break;
    case tagName:
        selectorBy = By.tagName(selectorValue);
        break;
    case cssSelector:
        selectorBy = By.cssSelector(selectorValue);
        break;
    case partialLinkText:
        selectorBy = By.partialLinkText(selectorValue);
        break;
    case wicketPathMatch:
        selectorBy = WicketBy.wicketPathMatch(selectorValue);
        break;
    case wicketPathContains:
        selectorBy = WicketBy.wicketPathContains(selectorValue);
        break;
    default:
        throw new AssertionError("unable to match selector " + selectorChoice.name());
    }

    return selectorBy;
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void findByPartialLinkText() {
    WebElement element = driver.findElement(By.partialLinkText("Text"));
    Assert.assertEquals("Text of link", element.getText());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void findElementsByPartialLinkText() {
    List<WebElement> findElements = driver.findElements(By.partialLinkText("Text"));
    Assert.assertEquals(2, findElements.size());
    findElements = driver.findElements(By.partialLinkText("Other link"));
    Assert.assertEquals(2, findElements.size());
    findElements = driver.findElements(By.partialLinkText("link"));
    Assert.assertEquals(4, findElements.size());
}

From source file:com.dukescript.api.selenium.FindsByTest.java

License:Open Source License

@Test
public void Element_findByPartialLinkText() {
    WebElement links = driver.findElement(By.id("links"));
    WebElement element = links.findElement(By.partialLinkText("Text"));
    Assert.assertEquals("Text of link", element.getText());
}