Example usage for org.openqa.selenium Keys ENTER

List of usage examples for org.openqa.selenium Keys ENTER

Introduction

In this page you can find the example usage for org.openqa.selenium Keys ENTER.

Prototype

Keys ENTER

To view the source code for org.openqa.selenium Keys ENTER.

Click Source Link

Usage

From source file:businesscomponents.ReportcomparisonComponents1.java

public void storePreReportValues() throws IOException, InterruptedException {

    //   newTab.clear();
    String Report = dataTable.getData("General_Data", "ReportName");
    //String winName = "Management Console - ["+Report+"]";
    //System.out.println("Window Name is : "+winName);

    oldTab = driver.getWindowHandle();//  ww w .  j a v a 2 s  .c  o  m

    //System.out.println("Old tab is : "+driver.getTitle());
    Thread.sleep(1000);
    newTab = new ArrayList<String>(driver.getWindowHandles());

    newTab.remove(oldTab);
    if (reportIterator > 1) {
        oldtab1 = driver.getWindowHandle();
        newTab.remove(oldtab1);
    }
    int s3 = newTab.size();

    if (s3 > 1) {
        driver.switchTo().window(newTab.get(s3 - 1));
        System.out.println("Window name in second Iteration is : " + driver.getTitle());
    } else {
        driver.switchTo().window(newTab.get(0));

    }
    Thread.sleep(1000);
    WebElement frame3 = driver.findElement(By.id("reportframe"));
    driver.switchTo().frame(frame3);
    try {
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String strPageVal = "";
    //Conditions for Different Reports

    if (Report.contains("MRF412")) {
        strPageVal = mObj.getPageNoMRF412().getText();

    } else if (Report.contains("MRF417")) {
        strPageVal = mObj.getPageNoMRF417().getText();
    } else if (Report.contains("MRF208")) {
        strPageVal = mObj.getPageNoMRF208().getText();
    } else if (Report.contains("MRO202")) {
        strPageVal = mObj.getPageNoMRF203n203().getText();
    } else if (Report.contains("MRO203")) {
        strPageVal = mObj.getPageNoMRF203n203().getText();
    } else {
        report.updateTestLog("Verify Report Name", "Invalid Report name", Status.FAIL);
    }

    ArrayList<String> strPartnerName1 = new ArrayList<String>();
    int intVarIncement = 0;
    int TotalPages = Integer.parseInt(strPageVal);
    String strPageTitle = mObj.getPageTitle().getText();
    //Condition for sampling 
    if (TotalPages > 25) {

        int LastPage = TotalPages;

        //for first page
        if (strPageTitle.contains("MultiUserTest License")) {
            report.updateTestLog("Verify Page Title", "Page Title Verification is successful for page 1",
                    Status.PASS);
            strPartnerName1 = mObj.getAllValuesFromPage1();
            page.add(strPartnerName1);
        } else {
            report.updateTestLog("Verify Page Title", "Page Title Verification failed for Page 1", Status.FAIL);
        }
        //for last page
        driver.switchTo().window(newTab.get(0));
        driver.switchTo().frame("toolbarframe");
        String lspage = Integer.toString(LastPage);
        //System.out.println("value is : " + lspage);
        mObj.getEditPageToolbar().clear();
        mObj.getEditPageToolbar().sendKeys(lspage);

        mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
        report.updateTestLog("Enter Last page", "Last Page is entered in Edit box", Status.DONE);
        Thread.sleep(1500);
        driver.switchTo().window(newTab.get(0));
        driver.switchTo().frame(frame3);
        strPageTitle = mObj.getPageTitle().getText();
        if (strPageTitle.contains("MultiUserTest License")) {
            report.updateTestLog("Verify Page Title", "Page Title Verification is successful for Last Page",
                    Status.PASS);
            strPartnerName1 = mObj.getAllValuesFromPage1();
            page.add(strPartnerName1);
        } else {
            report.updateTestLog("Verify Page Title", "Page Title Verification failed for Last Page",
                    Status.FAIL);
        }

        // For Other Pages
        if (s3 > 1) {
            driver.switchTo().window(newTab.get(1));
        } else {
            driver.switchTo().window(newTab.get(0));

        }
        driver.switchTo().frame("toolbarframe");
        mObj.getEditPageToolbar().clear();
        mObj.getEditPageToolbar().sendKeys("2");
        mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
        report.updateTestLog("Enter Second page", "Second Page is entered in Edit box", Status.DONE);
        Thread.sleep(1500);
        if (s3 > 1) {
            driver.switchTo().window(newTab.get(1));
        } else {
            driver.switchTo().window(newTab.get(0));

        }
        driver.switchTo().frame(frame3);
        for (int Pageiter1 = 1; Pageiter1 < 5; Pageiter1++)
        //   for (int Pageiter1 = 1; Pageiter1 < (TotalPages - 1); Pageiter1++) 
        {
            strPageTitle = mObj.getPageTitle().getText();
            intVarIncement = (int) Math.pow(2, Pageiter1);
            System.out.println("intVarIncement value is : " + intVarIncement);
            if (strPageTitle.contains("MultiUserTest License")) {
                report.updateTestLog("Verify Page Title",
                        "Page Title Verification is successful for page " + intVarIncement, Status.PASS);
                strPartnerName1 = mObj.getAllValuesFromPage1();
                page.add(strPartnerName1);
            } else {
                report.updateTestLog("Verify Page Title",
                        "Page Title Verification failed for Page " + intVarIncement, Status.FAIL);
            }

            if (s3 > 1) {
                driver.switchTo().window(newTab.get(1));
            } else {
                driver.switchTo().window(newTab.get(0));

            }

            driver.switchTo().frame("toolbarframe");
            Thread.sleep(1000);
            if (intVarIncement > TotalPages) {
                break;
            } else {
                mObj.getEditPageToolbar().clear();
                mObj.getEditPageToolbar().sendKeys(Integer.toString(intVarIncement));
                mObj.getEditPageToolbar().sendKeys(Keys.ENTER);
                synchronized (driver) {
                    driver.wait(1000);
                }

                if (s3 > 1) {
                    driver.switchTo().window(newTab.get(1));
                } else {
                    driver.switchTo().window(newTab.get(0));

                }
                WebElement frame3_upd = driver.findElement(By.id("reportframe"));
                driver.switchTo().frame(frame3_upd);
            }

        }
        pages.add(page);
    } else {
        pagenoPreReport = TotalPages;
        // Loop for storing values page by page
        for (int Pageiter = 0; Pageiter < TotalPages; Pageiter++) {
            String strPageSource = driver.getPageSource();
            CommonData.strPageSource = strPageSource;
            strPageTitle = mObj.getPageTitle().getText();

            CommonData.strPageTitle = strPageTitle;
            if (strPageTitle.contains("MultiUserTest License")) {

                report.updateTestLog("Verify Page Title",
                        "Page Title Verification is successful for page" + (Pageiter + 1), Status.PASS);
                String strPartnerNameList1;
                CommonData.strPageNumber = strPageVal;
                strPartnerName1 = mObj.getAllValuesFromPage1();
                page.add(strPartnerName1);
            } else {
                report.updateTestLog("Verify Page Title", "Page Title Verification", Status.FAIL);
            }
            if (s3 > 1) {
                driver.switchTo().window(newTab.get(s3 - 1));
            } else {
                driver.switchTo().window(newTab.get(0));

            }
            driver.switchTo().frame("toolbarframe");

            mObj.getNextLink().click();

            synchronized (driver) {
                driver.wait(1000);
            }
            if (s3 > 1) {

                driver.switchTo().window(newTab.get(s3 - 1));
            } else {
                driver.switchTo().window(newTab.get(0));

            }
            WebElement frame3_upd = driver.findElement(By.id("reportframe"));
            driver.switchTo().frame(frame3_upd);

        }

        pages.add(page);
    }
    report.updateTestLog("Storing Data", "Data has been stored for Pre report", Status.DONE);
    //End code for Pre Report
    driver.switchTo().defaultContent();
    driver.close();

    driver.switchTo().window(oldTab);
    driver.switchTo().defaultContent();
    driver.switchTo().frame("TableFrame");
    tObj.getCompletedLnk().click();
    Thread.sleep(1200);
    driver.switchTo().frame("ifrMainFrame");
}

From source file:ca.nrc.cadc.UserStorageBrowserPage.java

License:Open Source License

public void navToRoot() throws Exception {
    // opting for sendKeys because chromedriver
    // doesn't work for click() function for some reason. :(
    rootButton.sendKeys(Keys.ENTER);
}

From source file:com.actian.amc.pages.InstanceNewPage.java

public InstanceNewPage instanceCreationWizardScreen1(String instanceName, String instanceGrp,
        String instanceType) {//  w  w  w .j  av a 2 s  .c o m
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    int count = 0;

    try {
        driver.findElement(instanceNameField).clear();
        driver.findElement(instanceNameField).sendKeys(instanceName);
        driver.findElement(instanceNameField).sendKeys(Keys.ENTER);
        driver.findElement(instanceGroupField).clear();
        driver.findElement(instanceGroupField).sendKeys(instanceGrp);
        driver.findElement(instanceNameField).sendKeys(Keys.ENTER);
        if (driver.findElements(instanceNewExistingRadioList).size() > 0) { // Won't Exist for Matrix or AMC
            if (instanceType == "New") {
                List<WebElement> instanceTypes = driver.findElements(instanceNewExistingRadioList);
                instanceTypes.get(0).click();
            } else if (instanceType == "Existing") {
                List<WebElement> instanceTypes = driver.findElements(instanceNewExistingRadioList);
                instanceTypes.get(1).click();
            } else {
                System.out.println("The valid options are New and Existing");
            }
        }
        clickWizardButton("Wizard 1: ", "Next");
        if (!getDialogMessage().equals("")) {
            selectDialogButton("OK");
            count = count + 1;
        }
    } catch (NoSuchElementException | StaleElementReferenceException e) {
        System.out.println("Trying to recover from a NoSuchElementException :-");

    }
    return new InstanceNewPage(driver);
}

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

License:Apache License

public void click(MobileElement wdElement) throws Exception {
    waitForElementClickability(wdElement);
    try {/*from  w w w .j  a v a  2  s . c  o m*/
        wdElement.click();
    } catch (Exception f) {
        focus(wdElement);
        wdElement.sendKeys(Keys.ENTER);
    }
}

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

License:Apache License

public void click(WebElement wdElement) throws Exception {
    waitForElementClickability(wdElement);
    try {//  w  w  w.  j  a  v  a2s . c o  m
        wdElement.click();
    } catch (Exception f) {
        focus(wdElement);
        wdElement.sendKeys(Keys.ENTER);
    }
}

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

public void editNote() throws AWTException {
    waitTOSync();/*from   www. j  a v a 2 s  .c o  m*/
    waitTOSync();
    element("editNote").click();
    element("Note_Title").clear();
    element("Note_Title").sendKeys("Instructor edited Note");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");

    waitTOSync();
    WebElement element = driver.findElement(By.id("tinymce"));
    driver.findElement(By.id("tinymce")).clear();
    System.out.println("Editing note description in text input");
    //element.sendKeys(Keys.CONTROL + "a");
    element.sendKeys(Keys.CONTROL + "b");

    element.sendKeys("bold edited");

    element.sendKeys(Keys.CONTROL + "b");
    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("Italics edited");

    element.sendKeys(Keys.ENTER);
    element.sendKeys(Keys.CONTROL + "i");
    element.sendKeys("hyperlinked");
    element.sendKeys(Keys.chord(Keys.SHIFT, Keys.HOME));
    waitTOSync();
    switchToDefaultContent();
    switchToDockIFrame();
    element("hyperlink").click();

    windowHandle = driver.getWindowHandle();
    ArrayList<String> tabs2 = new ArrayList<String>(driver.getWindowHandles());
    driver.switchTo().window(tabs2.get(1));
    element("linkBox").clear();
    element("linkBox").sendKeys("http://google.com");
    element("LinkInsert").click();
    waitTOSync();
    driver.switchTo().window(windowHandle);
    System.out.println("window switched");
    switchToDefaultContent();
    switchToDockIFrame();
    switchToFrame("tinymce_editor_area_ifr");
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    waitTOSync();
    Assert.assertTrue(element("linkedText").isDisplayed(), "text is not linked");

    switchToDefaultContent();
    switchToDockIFrame();
    element("updateNode_Button").click();
    waitTOSync();
    String addedNote_Title = driver.findElement(By.xpath(".//ul[@class='plain']/li[1]/a")).getText();
    System.out.println(addedNote_Title);
    Assert.assertTrue(addedNote_Title.contains("edited Note"), "edited note is not displayed");

    WebElement bold = driver.findElement(By.xpath("//strong[contains(text(),'bold edited')]"));
    Assert.assertTrue(bold.isDisplayed(), "bold text does not appear");

    WebElement italics = driver.findElement(By.xpath("//em[contains(text(),'Italics edited')]"));
    Assert.assertTrue(italics.isDisplayed(), "italics text does not appear");

    ReportMsg.info("Instructor successfuly edited note");
}

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

public void addTextboxDescription(String desc) {

    // switchToFrame("distinct_activity_create_frame");
    waitTOSync();//from w  ww  .j a v a2  s.c o  m
    waitTOSync();
    waitTOSync();
    switchToFrame("bodyText_ifr");
    WebElement element = driver.findElement(By.id("tinymce"));
    driver.findElement(By.id("tinymce")).clear();
    System.out.println("Editing text box description in text input");
    element.sendKeys(Keys.CONTROL + "b");
    element.sendKeys(desc);
    element.sendKeys(Keys.ENTER);
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Clear and set text./*from   www  .j  a  va 2  s  . c  o  m*/
 * 
 * @param driver the driver
 * @param locator the locator
 * @param innerText the inner text
 * @param timeout the timeout
 */
public static void clearAndSetText(final WebDriver driver, final By locator, final String innerText,
        final Timeout timeout) {

    final WebElement element = getElement(driver, locator, timeout);
    Assert.assertNotNull(element, "Element cannot be null");
    element.clear();
    element.sendKeys(innerText);
    element.sendKeys(Keys.ENTER);
    WaitUtil.waitUntil(Timeout.ATOMIC_TIMEOUT);
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Clear and set text press enter./*from   w  ww  . j  av a 2s .  c  o  m*/
 * 
 * @param driver the driver
 * @param locator the locator
 * @param innerText the inner text
 * @param timeout the timeout
 */
public static void clearAndSetTextPressEnter(final WebDriver driver, final By locator, final String innerText,
        final Timeout timeout) {

    final WebElement element = getElement(driver, locator, timeout);
    element.clear();
    element.sendKeys(innerText);
    element.sendKeys(Keys.ENTER);
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Clear text./*from w w  w .j ava2  s . co m*/
 * 
 * @param driver the driver
 * @param locator the locator
 * @param timeout the timeout
 */
public static void clearText(final WebDriver driver, final By locator, final Timeout timeout) {

    final WebElement element = getElement(driver, locator, timeout);
    element.clear();
    element.sendKeys(Keys.ENTER);
}