Example usage for org.openqa.selenium By linkText

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

Introduction

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

Prototype

public static By linkText(String linkText) 

Source Link

Usage

From source file:edu.sampleu.main.PeopleFlowCreateNewAftBase.java

License:Educational Community License

protected void testPeopleFlowCreateNew() throws Exception {
    PeopleFlowDocInfo docInfo = peopleFlowCreateNew();

    waitAndClickSubmitByText();/*from www . j a v a2  s .  c  o  m*/
    waitAndClickConfirmSubmitOk();
    Thread.sleep(3000);
    checkForDocError();
    checkForIncidentReport();

    driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
    findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
    Thread.sleep(5000);
    jGrowl("Document Search is " + docInfo.getDocId() + " present?");
    selectFrameIframePortlet();
    waitAndTypeByName("documentId", docInfo.getDocId());
    jGrowl("Click search");
    findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
    waitForTextPresent(DOC_STATUS_FINAL);

    jGrowl("Find our PeopleFlow by lookup");
    driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
    waitAndClick(By.linkText("Main Menu"));
    Thread.sleep(3000);

    waitAndClick(By.linkText("People Flow"));
    waitForPageToLoad();
    selectFrameIframePortlet();
    waitAndTypeByName("lookupCriteria[name]", docInfo.getName());

    jGrowl("Click search");
    waitAndClickByXpath(SEARCH_XPATH_3);
    waitForPageToLoad();
    waitAndClickByLinkText("edit");
    waitForPageToLoad();

    jGrowl("verify the forceAction values for our two stops");
    assertFalse(findElement(By.name("document.newMaintainableObject.dataObject.members[0].forceAction"))
            .isSelected());
    assertTrue(findElement(By.name("document.newMaintainableObject.dataObject.members[1].forceAction"))
            .isSelected());
}

From source file:edu.sampleu.main.WorkFlowRouteRulesBlanketAppAftBase.java

License:Educational Community License

protected void testWorkFlowRouteRulesBlanketApp() throws Exception {
    String random = AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
    waitForPageToLoad();/*from w ww. j a  va 2  s.  c o m*/
    Thread.sleep(3000);
    assertEquals("Kuali Portal Index", getTitle());
    selectFrameIframePortlet();

    // click on the create new button
    waitAndClickCreateNew();

    // lookup on the Document Type Name
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:documentTypeName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor");

    // type in the name field the text RoutingRuleDocument
    waitAndTypeByName("name", "RoutingRuleDocument");

    // click the search button
    waitAndClickSearch();

    // click the return value link
    waitAndClickReturnValue();

    // lookup on the Rule Template Name
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kew.rule.bo.RuleTemplateBo!!).(((name:ruleTemplateName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor");

    // type in the name field the text RuleRoutingTemplate
    waitAndTypeByName("name", "RuleRoutingTemplate");

    // click the search button
    waitAndClickSearch();

    // click the return value link
    waitAndClickReturnValue("testWorkFlowRouteRulesBlanketApp");

    // click the create new button
    waitAndClickByName("methodToCall.createRule");
    waitForPageToLoad();
    String docId = waitForDocId();
    assertTrue(isElementPresentByName(CANCEL_NAME));

    // type in the Document Overview Description the text Test Routing Rule
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Test Routing Rule " + random);

    // click the Force Action checkbox
    waitAndClickByXpath("//input[@id='document.newMaintainableObject.forceAction']");

    // type in the Description text area the text Test Routing Rule1
    waitAndTypeByXpath("//textarea[@id='document.newMaintainableObject.description']",
            "Test Routing Rule1 " + random);

    // type in the Document type name field the text DocumentTypeDocument
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.fieldValues(1321~docTypeFullName)']",
            "DocumentTypeDocument");

    // lookup on Person
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalName:document.newMaintainableObject.add.personResponsibilities.principalName,))).((`document.newMaintainableObject.add.personResponsibilities.principalName:principalName,`)).((<>)).(([])).((**)).((^^)).((&&)).((/personImpl/)).((~~)).(::::;"
                    + getBaseUrlString() + "/kr/lookup.do;::::).anchor15");

    // click the search button
    waitAndClickSearch();

    // click the return value
    waitAndClickReturnValue();

    // select from the Action Request ACKNOWLEDGE
    selectByXpath("//select[@id='document.newMaintainableObject.add.personResponsibilities.actionRequestedCd']",
            "ACKNOWLEDGE");

    // type in the Priority field the text 1
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.add.personResponsibilities.priority']",
            "1");

    // click the add button
    waitAndClickByName(
            "methodToCall.addLine.personResponsibilities.(!!org.kuali.rice.kew.rule.PersonRuleResponsibility!!).(:::;15;:::).anchor15");
    waitForPageToLoad();

    // click Blanket Approve
    waitAndClickByName(BLANKET_APPROVE_NAME);

    // doc search for the docId
    waitForPageToLoad();
    driver.switchTo().defaultContent(); //selectWindow("null");
    waitAndClickDocSearch();
    waitForPageToLoad();
    assertEquals("Kuali Portal Index", getTitle());
    selectFrameIframePortlet();
    waitAndTypeByName("documentId", docId);
    waitAndClickSearch();

    // Expect the doc status to be FINAL
    waitForElementPresent(By.linkText(docId));
    if (isElementPresent(By.linkText(docId))) {
        if (!DOC_STATUS_FINAL.equalsIgnoreCase(getTextByXpath(DOC_STATUS_XPATH_2))) {
            jiraAwareFail("WorkFlowRouteRulesBlanketApp expected:<[FINAL]> but was "
                    + getTextByXpath(DOC_STATUS_XPATH_2));
        }
    } else {
        assertEquals(docId, getTextByXpath(DOC_ID_XPATH_2));
        assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2));
    }
}

From source file:edu.samplu.common.WebDriverITBase.java

License:Educational Community License

/**
 * /*from   w  ww . ja va 2 s .  co  m*/
 *
 * @param text text of the link
*/
protected void waitAndClickByLinkText(String text) throws InterruptedException {
    waitAndClick(By.linkText(text), "");
}

From source file:edu.samplu.common.WebDriverITBase.java

License:Educational Community License

/**
 * /*from   www  . j av a 2 s.c o  m*/
 *
 * @param text text of the link
 * @param message user defined message to display
*/
protected void waitAndClickByLinkText(String text, String message) throws InterruptedException {
    waitAndClick(By.linkText(text), message);
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

License:Educational Community License

protected void assertDocFinal(String docId) throws InterruptedException {
    jiraAwareWaitFor(By.linkText("spreadsheet"), "");

    if (isElementPresent(By.linkText(docId))) {
        SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getDocStatus());
    } else {/*  ww w.java2s  .co m*/
        SeleneseTestBase.assertEquals(docId, driver.findElement(By.xpath(DOC_ID_XPATH_2)));
        SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getDocStatus());
    }
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

License:Educational Community License

protected void assertElementPresentByLinkText(String linkText) {
    driver.findElement(By.linkText(linkText));
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

License:Educational Community License

protected boolean isElementPresentByLinkText(String locator) {
    return isElementPresent(By.linkText(locator));
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

License:Educational Community License

protected void testCreateSampleEDocLite() throws Exception {
    waitForPageToLoad();//from   www.  j a v a2  s .  c o m
    Thread.sleep(3000);
    SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle());
    selectFrameIframePortlet();
    waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
    waitForPageToLoad();

    // click on the create new.
    waitAndClickByLinkText("Create Document");
    waitForPageToLoad();
    Thread.sleep(3000);
    String docId = getTextByXpath("//table/tbody/tr[4]/td[@class='datacell1']");
    waitAndTypeByName("userName", "Viral Chauhan");
    waitAndTypeByName("rqstDate", "12/03/2020");
    checkByName("fundedBy");
    waitAndTypeByName("addText", "Note Added.");
    waitAndClickByXpath("//td[@class='datacell']/div/img");
    waitForPageToLoad();
    waitAndClickByXpath("//input[@value='submit']");
    SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='submit']"));
    SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='save']"));
    SeleneseTestBase.assertEquals(Boolean.FALSE, (Boolean) isElementPresentByXpath("//input[@value='cancel']"));
    waitForPageToLoad();
    selectTopFrame();
    waitAndClickDocSearch();
    waitForPageToLoad();
    selectFrameIframePortlet();
    waitAndClickByXpath("//input[@name='methodToCall.search' and @alt='search']");
    waitForPageToLoad();
    isElementPresent(By.linkText(docId));
}

From source file:edu.samplu.common.WebDriverLegacyITBase.java

License:Educational Community License

protected void testWorkFlowRouteRulesBlanketApp() throws Exception {
    waitForPageToLoad();//from w  w w . j  a  v  a  2  s .  c  o m
    Thread.sleep(3000);
    SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle());
    selectFrameIframePortlet();

    // click on the create new button
    waitAndClickCreateNew();
    waitForPageToLoad();

    // lookup on the Document Type Name
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kew.doctype.bo.DocumentType!!).(((name:documentTypeName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor");
    waitForPageToLoad();

    // type in the name field the text RoutingRuleDocument
    waitAndTypeByName("name", "RoutingRuleDocument");

    // click the search button
    waitAndClickSearch();
    waitForPageToLoad();

    // click the return value link
    waitAndClickReturnValue();
    waitForPageToLoad();

    // lookup on the Rule Template Name
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kew.rule.bo.RuleTemplateBo!!).(((name:ruleTemplateName))).((``)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;;::::).anchor");
    waitForPageToLoad();

    // type in the name field the text RuleRoutingTemplate
    waitAndTypeByName("name", "RuleRoutingTemplate");

    // click the search button
    waitAndClickSearch();
    waitForPageToLoad();

    // click the return value link
    waitAndClickReturnValue();
    waitForPageToLoad();

    // click the create new button
    waitAndClickByName("methodToCall.createRule");
    waitForPageToLoad();
    String docId = waitForDocId();
    SeleneseTestBase.assertTrue(isElementPresentByName(CANCEL_NAME));

    // type in the Document Overview Description the text Test Routing Rule
    waitAndTypeByXpath(DOC_DESCRIPTION_XPATH, "Test Routing Rule");

    // click the Force Action checkbox
    waitAndClickByXpath("//input[@id='document.newMaintainableObject.forceAction']");

    // type in the Description text area the text Test Routing Rule1
    waitAndTypeByXpath("//textarea[@id='document.newMaintainableObject.description']", "Test Routing Rule1");

    // type in the Document type name field the text DocumentTypeDocument
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.fieldValues(1321~docTypeFullName)']",
            "DocumentTypeDocument");

    // lookup on Person
    waitAndClickByName(
            "methodToCall.performLookup.(!!org.kuali.rice.kim.impl.identity.PersonImpl!!).(((principalName:document.newMaintainableObject.add.personResponsibilities.principalName,))).((`document.newMaintainableObject.add.personResponsibilities.principalName:principalName,`)).((<>)).(([])).((**)).((^^)).((&&)).((/personImpl/)).((~~)).(::::;"
                    + getBaseUrlString() + "/kr/lookup.do;::::).anchor15");
    waitForPageToLoad();

    // click the search button
    waitAndClickSearch();
    waitForPageToLoad();

    // click the return value
    waitAndClickReturnValue();
    waitForPageToLoad();

    // select from the Action Request ACKNOWLEDGE
    selectByXpath("//select[@id='document.newMaintainableObject.add.personResponsibilities.actionRequestedCd']",
            "ACKNOWLEDGE");

    // type in the Priority field the text 1
    waitAndTypeByXpath("//input[@id='document.newMaintainableObject.add.personResponsibilities.priority']",
            "1");

    // click the add button
    waitAndClickByName(
            "methodToCall.addLine.personResponsibilities.(!!org.kuali.rice.kew.rule.PersonRuleResponsibility!!).(:::;15;:::).anchor15");
    waitForPageToLoad();
    checkForIncidentReport(BLANKET_APPROVE_NAME);
    waitAndClickByName(BLANKET_APPROVE_NAME);
    waitForPageToLoad();
    driver.switchTo().defaultContent(); //selectWindow("null");
    Thread.sleep(2000);
    waitAndClickDocSearch();
    waitForPageToLoad();
    SeleneseTestBase.assertEquals("Kuali Portal Index", getTitle());
    selectFrameIframePortlet();
    waitAndClickSearch();
    waitForPageToLoad();
    SeleneseTestBase.assertTrue(isElementPresent(By.linkText(docId)));

    if (isElementPresent(By.linkText(docId))) {
        assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2),
                "https://jira.kuali.org/browse/KULRICE-9051 WorkFlow Route Rules Blanket Approval submit status results in Enroute, not Final");
    } else {
        SeleneseTestBase.assertEquals(docId, getTextByXpath(DOC_ID_XPATH_2));
        SeleneseTestBase.assertEquals(DOC_STATUS_FINAL, getTextByXpath(DOC_STATUS_XPATH_2));
    }
}