Example usage for org.openqa.selenium Keys CONTROL

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

Introduction

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

Prototype

Keys CONTROL

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

Click Source Link

Usage

From source file:com.test.Login_Validation.java

@Test(priority = 6)
public void Logged_Out_LicenseNetsuiteAccount() throws Throwable {
    Thread.sleep(4000);//from  w  w  w  . j  a va  2 s  .c o  m
    logger = Login.report.startTest("Logout From License NS Account");
    l.NsLogin(data.getProperty("Emailid"), data.getProperty("pwd"), logger);
    l.gmailLogin(logger);
    Thread.sleep(2000);
    driver.switchTo().frame(Login.getApp_frame());
    logger.log(LogStatus.INFO, "Opening new tab");
    hcl.openNewTab(driver);
    logger.log(LogStatus.INFO, "Navigating to Newly opened tab");
    hcl.navigateToNextTab(driver);
    l.changeNsRole(driver, "New Celigo QA for Productivity Scrum [Leading] (TSTDRV1143610)", logger);
    logger.log(LogStatus.INFO, "Switching back to gmail window");
    Thread.sleep(3000);

    ArrayList<String> allTabs = new ArrayList<String>(driver.getWindowHandles());
    driver.switchTo().window(allTabs.get(1));
    driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL + "w");
    driver.switchTo().window(allTabs.get(0));
    driver.switchTo().frame(Login.getApp_frame());
    String pop = driver.findElement(By.cssSelector("div.modal-content p")).getText();
    System.out.println(pop);
    logger.log(LogStatus.INFO, "Asserting Pop-up Text");
    if ("You have been logged out of your licensed NetSuite account.".equals(pop)) {
        System.out.println("popup displayed" + pop);

        logger.log(LogStatus.PASS, "pop is displayed with message [" + pop + "]");
    }

}

From source file:com.thoughtworks.selenium.webdriven.commands.SendKeys.java

License:Apache License

@Override
protected Void handleSeleneseCommand(WebDriver driver, String locator, String value) {
    alertOverride.replaceAlertMethod(driver);

    value = value.replace("${KEY_ALT}", Keys.ALT);
    value = value.replace("${KEY_CONTROL}", Keys.CONTROL);
    value = value.replace("${KEY_CTRL}", Keys.CONTROL);
    value = value.replace("${KEY_META}", Keys.META);
    value = value.replace("${KEY_COMMAND}", Keys.COMMAND);
    value = value.replace("${KEY_SHIFT}", Keys.SHIFT);

    value = value.replace("${KEY_BACKSPACE}", Keys.BACK_SPACE);
    value = value.replace("${KEY_BKSP}", Keys.BACK_SPACE);
    value = value.replace("${KEY_DELETE}", Keys.DELETE);
    value = value.replace("${KEY_DEL}", Keys.DELETE);
    value = value.replace("${KEY_ENTER}", Keys.ENTER);
    value = value.replace("${KEY_EQUALS}", Keys.EQUALS);
    value = value.replace("${KEY_ESCAPE}", Keys.ESCAPE);
    value = value.replace("${KEY_ESC}", Keys.ESCAPE);
    value = value.replace("${KEY_INSERT}", Keys.INSERT);
    value = value.replace("${KEY_INS}", Keys.INSERT);
    value = value.replace("${KEY_PAUSE}", Keys.PAUSE);
    value = value.replace("${KEY_SEMICOLON}", Keys.SEMICOLON);
    value = value.replace("${KEY_SPACE}", Keys.SPACE);
    value = value.replace("${KEY_TAB}", Keys.TAB);

    value = value.replace("${KEY_LEFT}", Keys.LEFT);
    value = value.replace("${KEY_UP}", Keys.UP);
    value = value.replace("${KEY_RIGHT}", Keys.RIGHT);
    value = value.replace("${KEY_DOWN}", Keys.DOWN);
    value = value.replace("${KEY_PAGE_UP}", Keys.PAGE_UP);
    value = value.replace("${KEY_PGUP}", Keys.PAGE_UP);
    value = value.replace("${KEY_PAGE_DOWN}", Keys.PAGE_DOWN);
    value = value.replace("${KEY_PGDN}", Keys.PAGE_DOWN);
    value = value.replace("${KEY_END}", Keys.END);
    value = value.replace("${KEY_HOME}", Keys.HOME);

    value = value.replace("${KEY_NUMPAD0}", Keys.NUMPAD0);
    value = value.replace("${KEY_N0}", Keys.NUMPAD0);
    value = value.replace("${KEY_NUMPAD1}", Keys.NUMPAD1);
    value = value.replace("${KEY_N1}", Keys.NUMPAD1);
    value = value.replace("${KEY_NUMPAD2}", Keys.NUMPAD2);
    value = value.replace("${KEY_N2}", Keys.NUMPAD2);
    value = value.replace("${KEY_NUMPAD3}", Keys.NUMPAD3);
    value = value.replace("${KEY_N3}", Keys.NUMPAD3);
    value = value.replace("${KEY_NUMPAD4}", Keys.NUMPAD4);
    value = value.replace("${KEY_N4}", Keys.NUMPAD4);
    value = value.replace("${KEY_NUMPAD5}", Keys.NUMPAD5);
    value = value.replace("${KEY_N5}", Keys.NUMPAD5);
    value = value.replace("${KEY_NUMPAD6}", Keys.NUMPAD6);
    value = value.replace("${KEY_N6}", Keys.NUMPAD6);
    value = value.replace("${KEY_NUMPAD7}", Keys.NUMPAD7);
    value = value.replace("${KEY_N7}", Keys.NUMPAD7);
    value = value.replace("${KEY_NUMPAD8}", Keys.NUMPAD8);
    value = value.replace("${KEY_N8}", Keys.NUMPAD8);
    value = value.replace("${KEY_NUMPAD9}", Keys.NUMPAD9);
    value = value.replace("${KEY_N9}", Keys.NUMPAD9);
    value = value.replace("${KEY_ADD}", Keys.ADD);
    value = value.replace("${KEY_NUM_PLUS}", Keys.ADD);
    value = value.replace("${KEY_DECIMAL}", Keys.DECIMAL);
    value = value.replace("${KEY_NUM_PERIOD}", Keys.DECIMAL);
    value = value.replace("${KEY_DIVIDE}", Keys.DIVIDE);
    value = value.replace("${KEY_NUM_DIVISION}", Keys.DIVIDE);
    value = value.replace("${KEY_MULTIPLY}", Keys.MULTIPLY);
    value = value.replace("${KEY_NUM_MULTIPLY}", Keys.MULTIPLY);
    value = value.replace("${KEY_SEPARATOR}", Keys.SEPARATOR);
    value = value.replace("${KEY_SEP}", Keys.SEPARATOR);
    value = value.replace("${KEY_SUBTRACT}", Keys.SUBTRACT);
    value = value.replace("${KEY_NUM_MINUS}", Keys.SUBTRACT);

    value = value.replace("${KEY_F1}", Keys.F1);
    value = value.replace("${KEY_F2}", Keys.F2);
    value = value.replace("${KEY_F3}", Keys.F3);
    value = value.replace("${KEY_F4}", Keys.F4);
    value = value.replace("${KEY_F5}", Keys.F5);
    value = value.replace("${KEY_F6}", Keys.F6);
    value = value.replace("${KEY_F7}", Keys.F7);
    value = value.replace("${KEY_F8}", Keys.F8);
    value = value.replace("${KEY_F9}", Keys.F9);
    value = value.replace("${KEY_F10}", Keys.F10);
    value = value.replace("${KEY_F11}", Keys.F11);
    value = value.replace("${KEY_F12}", Keys.F12);

    finder.findElement(driver, locator).sendKeys(value);

    return null;/*from ww w. j  a v  a 2  s  .c om*/
}

From source file:com.vaadin.addon.charts.testbenchtests.RangeSelectorCustomDateParserTBTest.java

private void setRangeValue(String value, WebElement input) {
    Actions action = new Actions(driver);
    //Should be done as one action, otherwise does not work
    action.doubleClick(input).sendKeys(Keys.chord(Keys.CONTROL, "a")).sendKeys(Keys.BACK_SPACE).sendKeys(value)
            .sendKeys(Keys.TAB).perform();
}

From source file:com.vaadin.testbench.elements.ColorPickerPreviewElement.java

License:Apache License

/**
 * Set value of TextField in ColorPickerPreview. Any existing value in the
 * field is replaced./*  ww w .  ja  v a  2 s. c om*/
 *
 * @param value
 *            text to insert
 *
 * @since 8.4
 */
public void setColorTextFieldValue(String value) {
    // Select all text
    getColorTextField().sendKeys(Keys.chord(Keys.CONTROL, "a"));
    getColorTextField().sendKeys(value);
}

From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridEditorUnbufferedTest.java

License:Apache License

@Test
public void testValidationErrorPreventsMove() throws InterruptedException {
    // Because of "out of view" issues, we need to move this for easy access
    selectMenuPath("Component", "Columns", "Column 7", "Column 7 Width", "50px");
    for (int i = 0; i < 6; ++i) {
        selectMenuPath("Component", "Columns", "Column 7", "Move left");
    }/*from  www . j a  v a  2 s.c om*/

    selectMenuPath(EDIT_ITEM_5);

    getEditorWidgets().get(1).click();
    String faultyInt = "not a number";
    getEditorWidgets().get(1).sendKeys(faultyInt);

    getGridElement().getCell(10, 0).click();

    assertEquals("Editor should not move from row 5", "(5, 0)",
            getEditorWidgets().get(0).getAttribute("value"));

    getEditorWidgets().get(1).sendKeys(Keys.chord(Keys.CONTROL, "a"));
    getEditorWidgets().get(1).sendKeys("5");
    // FIXME: Needs to trigger one extra validation round-trip for now
    getGridElement().sendKeys(Keys.ENTER);

    getGridElement().getCell(10, 0).click();

    assertEquals("Editor should move to row 10", "(10, 0)", getEditorWidgets().get(0).getAttribute("value"));

}

From source file:com.vaadin.tests.components.orderedlayout.OrderedLayoutExpandTest.java

License:Apache License

@Test
public void testNoAbortingLayoutAfter100PassesError() throws Exception {
    setDebug(true);//  w  ww.  j a v  a2 s  .  c  o m
    openTestURL();

    if (!getDesiredCapabilities().equals(Browser.CHROME.getDesiredCapabilities())) {
        // Chrome uses css to to set zoom level to 110% that is known to
        // cause issues with the test app.
        // Other browsers tries to set browser's zoom level directly.
        WebElement html = driver.findElement(By.tagName("html"));
        // reset to 100% just in case
        html.sendKeys(Keys.chord(Keys.CONTROL, "0"));
        // zoom browser to 75% (ie) or 90% (FF). It depends on browser
        // how much "Ctrl + '-'" zooms out.
        html.sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT));
    }

    // open debug window's Examine component hierarchy tab
    openDebugExamineComponentHierarchyTab();

    // click "Check layouts for potential problems" button
    clickDebugCheckLayoutsForPotentialProblems();

    // find div containing a successful layout analyze result
    WebElement pass = findLayoutAnalyzePassElement();
    // find div containing a error message with
    // "Aborting layout after 100 passess" message.
    WebElement error = findLayoutAnalyzeAbortedElement();

    Assert.assertNull(error);
    Assert.assertNotNull(pass);

    if (!getDesiredCapabilities().equals(Browser.CHROME.getDesiredCapabilities())) {
        WebElement html = driver.findElement(By.tagName("html"));
        // reset zoom level back to 100%
        html.sendKeys(Keys.chord(Keys.CONTROL, "0"));
    }
}

From source file:com.vaadin.tests.components.window.CloseShortcutTest.java

License:Apache License

private void attemptCtrlShortcut() {
    window.focus();/*www . j  av  a 2 s . c  o  m*/
    new Actions(driver).keyDown(Keys.CONTROL).perform();
    $(TextFieldElement.class).first().sendKeys("A");
    new Actions(driver).keyUp(Keys.CONTROL).perform();
}

From source file:Config.LoginModule.java

public static void set_Email() {
    // GenerateData genData = new GenerateData();
    // String email = genData.generateEmail(15);
    driver.findElement(By.id("merchant_email")).sendKeys(Keys.chord(Keys.CONTROL, "a"), merchantEmail);
    driver.findElement(By.id("merchant_email_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),
            merchantEmail);//from   w  w w  .ja  v a2 s .  c  o  m
    // Start : This piece of code takes data from testdata java class and does testing for each type of data
    // for (String item : TestData.Emaillist ) {
    //  try {
    //     driver.findElement(By.id("merchant_email")).sendKeys(Keys.chord(Keys.CONTROL, "a"),item);
    //driver.findElement(By.id("merchant_email_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),item);
    //   Thread.sleep(1000);
    // if(driver.findElement(By.cssSelector("div[class = 'input email required merchant_email field_with_errors field_with_hint']")).isDisplayed())
    //{
    //  try {
    //    str = str+1;
    //  System.out.println("str value is "+str);

    //desc = "Email field should be valida format. User must put valid email to start signup The value" +item +"is invalid format for signup email";
    // Demo d31 = new Demo(str,"User details - Invalid format email field validation",desc,"Pass");
    //Map<Integer, Demo > testresultdata = new HashMap<>();
    //testresultdata.put(d31.getkey(),d31);
    //Thread.sleep(1000);
    //} catch (InterruptedException ex) {
    //  Logger.getLogger(LoginModule.class.getName()).log(Level.SEVERE, null, ex);
    //}

    //}
    //else
    //{
    //  try {
    //    str = str+1;
    //  System.out.print("str value is " +str);
    // System.out.print("div is not visible");
    // desc = "Email entered should be valid format.User must put an email in valid format to start sign up page";
    //Demo d31 = new Demo(str,"User details - Invalid format email field validation",desc,"Fail");
    //Map<Integer, Demo > testresultdata = new HashMap<>();
    //testresultdata.put(d31.getkey(),d31);
    //Thread.sleep(1000);
    //} catch (InterruptedException ex) {
    //   Logger.getLogger(LoginModule.class.getName()).log(Level.SEVERE, null, ex);
    //}
    //      } 
    //catch (InterruptedException ex) {
    ////         Logger.getLogger(LoginModule.class.getName()).log(Level.SEVERE, null, ex);
    //  }
    //     }
    // End : This piece of code takes data from testdata java class and does testing for each type of data
}

From source file:Config.m1SignupCreatemerchant.java

public void createMerchant() throws InterruptedException {

    /*// w ww  .jav  a  2  s .c  o m
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */

    /*
    @Author : Payal Verma
    @Description : .This is test step 1 to open the merchant Signup page in Intrnet explorer
    @GroovyTestStepName : "Launch SignUp Page"
    */
    //import com.eviware.soapui.model.testsuite.TestRunner.Status; 

    ((JavascriptExecutor) driver).executeScript(
            " var checkboxes =  document.getElementsByName('disclaimer[accepts]');for(var i=0, n=checkboxes.length;i<n;i++) { checkboxes[i].checked = true }");

    driver.findElement(By.name("commit")).click();

    driver.findElement(By.linkText("Next")).click();

    GenerateData genData = new GenerateData();
    // String URL = genData.generateEmail(20);

    driver.findElement(By.id("merchant_email")).sendKeys(Keys.chord(Keys.CONTROL, "a"), merchantEmail);

    driver.findElement(By.id("merchant_email_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),
            merchantEmail);

    String Password = genData.generateRandomAlphaNumeric(15);
    System.out.println("Password Generated is : " + Password);

    driver.findElement(By.id("merchant_password")).sendKeys(Keys.chord(Keys.CONTROL, "a"), Password);

    driver.findElement(By.id("merchant_password_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),
            Password);

    driver.findElement(By.linkText("Next")).click();
    Thread.sleep(1000);

    while (driver
            .findElement(By.cssSelector(
                    "div[class = 'input password required merchant_password'] span[class='error']"))
            .isDisplayed()
            || driver
                    .findElement(By.cssSelector(
                            "div[class = 'input email required merchant_email'] span[class='error']"))
                    .isDisplayed()) {
        Password = genData.generateRandomAlphaNumeric(15);
        System.out.println("Password Generated is : " + Password);

        driver.findElement(By.id("merchant_email")).sendKeys(Keys.chord(Keys.CONTROL, "a"), merchantEmail);

        Thread.sleep(1000);
        driver.findElement(By.id("merchant_email_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),
                merchantEmail);

        Thread.sleep(1000);

        driver.findElement(By.id("merchant_password")).sendKeys(Keys.chord(Keys.CONTROL, "a"), Password);

        Thread.sleep(1000);
        driver.findElement(By.id("merchant_password_confirmation")).sendKeys(Keys.chord(Keys.CONTROL, "a"),
                Password);

        driver.findElement(By.linkText("Next")).click();
        Thread.sleep(1000);
    }

    selectentitytype(driver);

    while (driver
            .findElement(By.cssSelector(
                    "div[class = 'input select required merchant_legal_form'] span[class='error']"))
            .isDisplayed()) {
        selectentitytype(driver);
    }

    Thread.sleep(1000);

    DBAValidation(driver);

    categorySubcategory(driver);

    Thread.sleep(1000);
    while (driver
            .findElement(By.cssSelector(
                    "div[class = 'input select optional merchant_company_category'] span[class='error']"))
            .isDisplayed()
            || driver
                    .findElement(By.cssSelector(
                            "div[class = 'input select optional merchant_company_type'] span[class='error']"))
                    .isDisplayed()) {
        categorySubcategory(driver);
    }

    merchantwebsitevalidation(driver);
    //Start : Merchant Attribute check
    Select selectMerchantPrefix = new Select(
            driver.findElement(By.id("merchant_contact_person_attributes_prefix")));

    int iMerchantPrefix = selectMerchantPrefix.getOptions().size();
    Thread.sleep(1000);

    Assert.assertEquals(4, iMerchantPrefix);

    Thread.sleep(1000);

    selectMerchantPrefix.selectByValue("");
    Assert.assertEquals("Please Select", selectMerchantPrefix.getFirstSelectedOption().getText());

    Thread.sleep(1000);
    selectMerchantPrefix.selectByValue("Mr");
    Assert.assertEquals("Mr", selectMerchantPrefix.getFirstSelectedOption().getText());
    Thread.sleep(1000);
    selectMerchantPrefix.selectByValue("Ms");
    Assert.assertEquals("Ms", selectMerchantPrefix.getFirstSelectedOption().getText());
    Thread.sleep(1000);
    selectMerchantPrefix.selectByValue("Mrs");
    Assert.assertEquals("Mrs", selectMerchantPrefix.getFirstSelectedOption().getText());

    //End : Merchant Attribute check

    //Start : Merchant Gender check
    Select selectMerchantGender = new Select(
            driver.findElement(By.id("merchant_contact_person_attributes_gender")));

    int iMerchantGender = selectMerchantGender.getOptions().size();
    Thread.sleep(1000);

    Assert.assertEquals(3, iMerchantGender);

    Thread.sleep(1000);

    selectMerchantGender.selectByValue("");
    Assert.assertEquals("Please Select", selectMerchantGender.getFirstSelectedOption().getText());

    Thread.sleep(1000);
    selectMerchantGender.selectByValue("Male");
    Assert.assertEquals("Male", selectMerchantGender.getFirstSelectedOption().getText());
    Thread.sleep(1000);
    selectMerchantGender.selectByValue("Female");
    Assert.assertEquals("Female", selectMerchantGender.getFirstSelectedOption().getText());
    Thread.sleep(1000);

    //End : Merchant Gender check

    Thread.sleep(1000);

    merchantfirstlastnamevalidation(driver);

    Thread.sleep(1000);
    driver.findElement(By.linkText("Next")).click();
    Thread.sleep(1000);

    merchantsveamount(driver);

}

From source file:Config.m1SignupCreatemerchant.java

public void DBAValidation(org.openqa.selenium.WebDriver driver) throws InterruptedException {

    GenerateData genData = new GenerateData();

    String DBAfinal = "MONETST" + genData.generateRandomString(5);
    driver.findElement(By.id("merchant_company_dba")).sendKeys(Keys.chord(Keys.CONTROL, "a"), DBAfinal);
    driver.findElement(By.linkText("Next")).click();
    String BS = "Business Summary :" + genData.generateRandomString(50);
    driver.findElement(By.id("merchant_business_summary")).sendKeys(Keys.chord(Keys.CONTROL, "a"), BS);
    driver.findElement(By.linkText("Next")).click();
    Thread.sleep(1000);/*w w  w  . j  a v a2  s. c o  m*/

}