Example usage for org.openqa.selenium By xpath

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

Introduction

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

Prototype

public static By xpath(String xpathExpression) 

Source Link

Usage

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

/**
* Save distinct google doc activity.//from  w ww.  j a  v a2  s.  c  o m
*
* @param title the title
*/
void saveDistinctGoogleDocActivity(String title) {
    try {
        element("title_inputField").clear();
        element("title_inputField").sendKeys(title);
    } catch (Exception e) {
        //To avoid stale element exception
        driver.findElement(By.xpath("//input[contains(@class,'required validates')]")).clear();
        driver.findElement(By.xpath("//input[contains(@class,'required validates')]")).sendKeys(title);
    }
    selectOrder();
    waitForElementPresent("save_btn");
    //element("save_btn").click();
    //clickOnElementUsingActionBuilder(element("save_btn"));
    executeJavascript("document.getElementById('init_save').click();");
}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

/**
     * Edits the distinct google doc activity.
     *//from   w  w  w  .jav a 2 s.  co  m
     * @param title the title
     */
public void editDistinctGoogleDriveActivity(String title) {
    int i = 0;
    //while(nb_list.get(i)){
    System.out.println(title);
    if (nb_list.get(0).getText().contains(title)) {
        String bookClassName = nb_list.get(i).getAttribute("class").toString();
        System.out.println("book class name ........." + bookClassName);
        executeJavascript("document.getElementsByClassName('" + bookClassName
                + "')[0].getElementsByClassName('nb_edit')[0].style.display = 'block';");
        waitTOSync();
        waitTOSync();
        driver.findElement(By.xpath("(//h3[@class='lpn_name' and contains(.,'" + title
                + "')]/parent::*/parent::*//img[@alt='Edit'])[1]")).click();

        saveDistinctGoogleDocActivity(title);
        //      break;
        // }
        //i++;
    }
}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

public void studentVerifyGoogleDriveApp() {

    performClickOnMoreLink();/*w w  w. j  a  v  a  2  s .  co m*/
    element("googleDriveIcon_stu").click();
    //driver.switchTo().frame(dockFrame)
    switchToDockIFrame();
    Assert.assertTrue(
            driver.findElement(By.xpath("//tr[contains(@class,'googledocument')]//a[@class='ng-binding']"))
                    .isEnabled(),
            "document is not shared");
    verifyFilteringOptions();
    verifySortingOperations();
    deselectFrame();

}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

/**
    * Verify presence of distinct activity.
    *//from   w ww. j  a v  a  2 s  .c  o  m
    * @param title the title
    * @return true, if successful
    */

public boolean verifyPresenceOfDistinctActivity(String title) {

    waitTOSync();
    resetImplicitTimeout(10);
    List<WebElement> nb_list = driver.findElements(By.xpath("//div[@class='lpn_thumbTitle']/h3"));
    for (WebElement unit : nb_list) {
        String unitName = unit.getText();
        if (unitName.contains(title)) {
            return true;
        }
    }
    return false;

}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

public void verifyAccountIsDeleted() {

    element("myContent").click();
    switchToDockIFrame();/*  w  w  w .java 2s.co m*/
    String head = element("mycontent_title").getText();
    if (head.contains("Kaltura"))
        ;
    driver.findElement(By.xpath("//a[contains(@title,'Google Drive')]")).click();
    switchToAppIFrame();
    element("signIn_btn").click();

}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

/**
 * Delete account./*from www .  j a  v  a 2 s .co  m*/
 *
 * @param gmailID the gmail id
 * @param password the password
 */

public void DeleteGoogleDriveAccount(String gmailID, String password) {

    //performClickOnMoreLink()

    element("myContent").click();
    switchToDockIFrame();
    String head = element("mycontent_title").getText();
    if (head.contains("Kaltura"))
        ;
    driver.findElement(By.xpath("//a[contains(@title,'Google Drive')]")).click();
    switchToAppIFrame();
    try {
        acceptAlertWindow();
    } catch (Exception e) {

    }

    waitForElementPresent("manageAccounts");
    //element("manageAccounts").click();
    executeJavascript("document.getElementById('AccountsMngmntId').click();");

    try {
        waitForElementPresent("back_btn");
        element("back_btn").click();
    } catch (Exception e) {
        refreshPage();
        element("myContent").click();
        switchToDockIFrame();
        switchToAppIFrame();
    }
    waitForElementPresent("manageAccounts");
    //clickOnElementUsingActionBuilder(element("manageAccounts"));
    //element("manageAccounts").click();
    executeJavascript("document.getElementById('AccountsMngmntId').click();");
    waitTOSync();
    waitForElementPresent("removeAccount");
    executeJavascript("document.getElementsByClassName('removeActiveAcct')[0].click();");
    //element("removeAccount").click();
    waitForElementPresent("continueButton");
    element("continueButton").click();
    deselectFrame();
    String winHandler = driver.getWindowHandle();
    try {
        resetImplicitTimeout(2);
        accountSettingWindow(gmailID, password);
    } catch (Exception e) {
        //takeScreenShotMethod();
    }
    resetImplicitTimeout(AJAX_WAIT);
    driver.switchTo().window(winHandler);

}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

/**
 * Account setting window.//from w  w w  . j a  va2  s.c  o  m
 *
 * @param gmailID the gmail id
 * @param password the password
 */
public void accountSettingWindow(String gmailID, String password) {
    for (String handle : driver.getWindowHandles()) {
        driver.switchTo().window(handle);
    }
    driver.manage().window().maximize();
    try {
        resetImplicitTimeout(2);
        waitForElementPresent("accountHomepage");
        element("accountHomepage").click();
        Thread.sleep(5000);
        //To avoid stale element exception
        driver.findElement(By.id("nav-security"));
        element("security").click();
    } catch (Exception e) {
        waitForElementPresent("signIn_icon");
        element("signIn_icon").click();
        loginToGoogleAccount(gmailID, password);
        driver.findElement(By.linkText("About the Sign in Request page")).click();
        //waitForElementDisplayed(accountHomepage);
        element("accountHomepage").click();
        //waitForElementDisplayed(security);
        element("security").click();
    }
    resetImplicitTimeout(AJAX_WAIT);
    //waitForElementDisplayed(manageAccess);
    element("manageAccess").click();
    //waitForElementDisplayed(revokeAccess);
    element("revokeAccess").click();
    //waitForElementDisplayed(ok_btn);
    element("ok_btn").click();
    //waitToSync();
    driver.findElement(By.xpath("//a[contains(@title,'" + gmailID + "')]")).click();
    //waitForElementDisplayed(signOut_link);
    element("signOut_link").click();
    //waitToSync();
    driver.close();
}

From source file:com.cengage.mindtap.keywords.GoogleDriveAppPageActions.java

public void selectShowFilesCheckbox() {
    driver.findElement(By.xpath("//input[@id='showDocs']")).click();
}

From source file:com.cengage.mindtap.keywords.InsiteAppPageActions.java

public void clickOnGoogleDrive() {
    driver.switchTo().frame(driver.findElement(By.xpath("//div[@id='upload-modal']//iframe")));
    waitForSpinnerToDisappear();// w w  w.  jav  a  2 s.  c  om
    element("additionalOption").click();
    element("googleDrive").click();
    //deselectFrame();
}

From source file:com.cengage.mindtap.keywords.InsiteAppPageActions.java

public void clickOnCopyPasteButton() {
    driver.switchTo().frame(driver.findElement(By.xpath("//div[@id='upload-modal']//iframe")));
    element("copyPaste_Button").click();
}