Example usage for org.openqa.selenium Keys META

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

Introduction

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

Prototype

Keys META

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

Click Source Link

Usage

From source file:com.lazerycode.ebselen.CreateTestCode.java

License:Apache License

public String convertCommandToEbselenCode(String seleniumCommand, String target, String value)
        throws Exception {
    ideCommand command;//from  ww w  .  j a  va2s .c  o m
    try {
        command = ideCommand.valueOf(seleniumCommand.trim().toUpperCase());
    } catch (Exception ex) {
        throw new IDECommandNotFoundException("Unable to match command to known list of commands!");
    }
    //TODO remove variable below
    String testData = "";
    switch (command) {
    case ADDLOCATIONSTRATEGY:
    case ADDLOCATIONSTRATEGYANDWAIT:
        return "LOGGER.warn(\"Custom locator strategies are not supported!\")";
    case ADDSCRIPT:
    case ADDSCRIPTANDWAIT:
        //                    LOGGER.error("Function not implemented yet.  Raise a request to get it implemented");
        //TODO
    case ADDSELECTION:
    case ADDSELECTIONANDWAIT:
        return select.selectByVisibleText(target, value);
    case ALLOWNATIVEXPATH:
    case ALLOWNATIVEXPATHANDWAIT:
        return "LOGGER.warn(\"Modifying the XPath implementation mid test is not supported!\")";
    case ALTKEYDOWN:
    case ALTKEYDOWNANDWAIT:
        return action.keyboard().pressKey(Keys.ALT);
    case ALTKEYUP:
    case ALTKEYUPANDWAIT:
        return action.keyboard().releaseKey(Keys.ALT);
    case ANSWERONNEXTPROMPT:
        return driver.switchTo().alert().sendKeys(target);
    case ASSERTALERT:
        return com.assertEquals(driver.switchTo().alert().getText(), value);
    case ASSERTALERTNOTPRESENT:

        //TODO
    case ASSERTALERTPRESENT:
        //TODO
    case ASSERTALLBUTTONS:
        //TODO
    case ASSERTALLFIELDS:
        //TODO
    case ASSERTALLLINKS:
        //TODO
    case ASSERTALLWINDOWIDS:
        //TODO
    case ASSERTALLWINDOWNAMES:
        //TODO
    case ASSERTALLWINDOWTITLES:
        //TODO
    case ASSERTATTRIBUTE:
        //TODO
    case ASSERTATTRIBUTEFROMALLWINDOWS:
        //TODO
    case ASSERTBODYTEXT:
        //TODO
    case ASSERTCHECKED:
        return com.assertTrue(ebselen.element().isChecked(target));
    case ASSERTCONFIRMATION:
        //TODO
    case ASSERTCONFIRMATIONNOTPRESENT:
        //TODO
    case ASSERTCONFIRMATIONPRESENT:
        //TODO
    case ASSERTCOOKIE:

        //TODO
    case ASSERCOOKIEBYNAME:
        return com.assertEquals(driver.manage().getCookieNamed(target), value);
    case ASSERTCOOKIENOTPRESENT:
        //TODO
    case ASSERTCOOKIEPRESENT:
        //TODO
    case ASSERTCSSCOUNT:
        return com.assertEquals(driver.findElements(loc.locatorAsString(target)).size(), value);
    case ASSERTCURSORPOSITION:
        //TODO only for input element of textarea gets numerical position of cursor in field
    case ASSERTEDITABLE:
        return com.assertTrue(driver.findElement(loc.locatorAsString(target)).isEnabled());
    case ASSERTELEMENTHEIGHT:
        return com.assertEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("height"), value);
    case ASSERTELEMENTINDEX:
        //TODO
    case ASSERTELEMENTNOTPRESENT:
        return com.assertFalse(ebselen.element().doesElementExist(loc.locatorAsString(target)));
    case ASSERTELEMENTPOSITIONLEFT:
        //TODO
    case ASSERTELEMENTPOSITIONTOP:
        //TODO
    case ASSERTELEMENTPRESENT:
        return com.assertTrue(ebselen.element().doesElementExist(loc.locatorAsString(target)));
    case ASSETELEMENTWIDTH:
        return com.assertEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("width"), value);
    case ASSERTEVAL:
        //TODO
    case ASSERTEXPRESSION:
        //TODO
    case ASSERTHTMLSOURCE:
        //TODO
    case ASSERTLOCATION:
        return com.assertEquals(driver.getCurrentUrl(), target);
    case ASSERTMOUSESPEED:
        //TODO
    case ASSERTNOTALERT:
        //TODO
    case ASSERTNOTALLBUTTONS:
        //TODO
    case ASSERTNOTALLFIELDS:
        //TODO
    case ASSERTNOTALLLINKS:
        //TODO
    case ASSERTNOTALLWINDOWIDS:
        //TODO
    case ASSERTNOTALLWINDOWNAMES:
        //TODO
    case ASSERTNOTALLWINDOWTITLES:
        //TODO
    case ASSERTNOTATTRIBUTE:
        //TODO
    case ASSERTNOTATTRIBUTEFROMALLWINDOWS:
        //TODO
    case ASSERTNOTBODYTEXT:
        //TODO
    case ASSERTNOTCHECKED:
        return com.assertFalse(ebselen.element().isChecked(target));
    case ASSERTNOTCONFIRMATION:
        //TODO
    case ASSERTNOTCOOKIE:
        //TODO
    case ASSERTNOTCOOKIEBYNAME:
        //TODO
    case ASSERTNOTCSSCOUNT:
        return com.assertNotEquals(driver.findElements(loc.locatorAsString(target)).size(), value);
    case ASSERTNOTCURSORPOSITION:
        //TODO
    case ASSERTNOTEDITABLE:
        return com.assertFalse(driver.findElement(loc.locatorAsString(target)).isEnabled());
    case ASSERTNOTELEMENTHEIGHT:
        //TODO
    case ASSERTNOTELEMENTINDEX:
        //TODO
    case ASSERTNOTELEMENTPOSITIONLEFT:
        //TODO
    case ASSERTNOTELEMENTPOSITIONTOP:
        //TODO
    case ASSERTNOTELEMENTWIDTH:
        //TODO
    case ASSERTNOTEVAL:
        //TODO
    case ASSERTNOTEXPRESSION:
        //TODO
    case ASSERTNOTHTMLSOURCE:
        //TODO
    case ASSERTNOTLOCATION:
        //TODO
    case ASSERTNOTMOUSESPEED:
        //TODO
    case ASSERTNOTORDERED:
        //TODO
    case ASSERTNOTPROMPT:
        //TODO
    case ASSERTNOTSELECTOPTIONS:
        //TODO
    case ASSERTNOTSELECTEDID:
        //TODO
    case ASSERTNOTSELECTEDIDS:
        //TODO
    case ASSERTNOTSELECTEDINDEX:
        //TODO
    case ASSERTNOTSELECTEDINDEXES:
        //TODO
    case ASSERTNOTSELECTELABEL:
        //TODO
    case ASSERTNOTSELECTEDLABELS:
        //TODO
    case ASSERTNOTSELECTEDVALUE:
        //TODO
    case ASSERTNOTSELECTEDVALUES:
        //TODO
    case ASSERTNOTSOMETHINGSELECTED:
        //TODO
    case ASSERTNOTSPEED:
        //TODO
    case ASSERTNOTTABLE:
        //TODO
    case ASSERTNOTTEXT:
        //TODO
    case ASSERTNOTTITLE:
        //TODO
    case ASSERTNOTVALUE:
        //TODO
    case ASSERTNOTVISIBLE:
        //TODO
    case ASSERTNOTWHETHERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case ASSERTNOTWHETHERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case ASSERTNOTXPATHCOUNT:
        return com.assertNotEquals(value, driver.findElements(loc.locatorAsString(target)).size());
    case ASSERTORDERED:
        //TODO
    case ASSERTPROMPT:
        //TODO
    case ASSERTPROMPTNOTPRESENT:
        //TODO
    case ASSERTPROMPTPRESENT:
        //TODO
    case ASSERTSELECTOPTIONS:
        //TODO
    case ASSERTSELECTEDID:
        //TODO
    case ASSERTSELECTEDIDS:
        //TODO
    case ASSERTSELECTEDINDEX:
        //TODO
    case ASSERTSELECTEDINDEXES:
        //TODO
    case ASSERTSELECTEDLABEL:
        //TODO
    case ASSERTSELECTEDLABELS:
        //TODO
    case ASSERTSELECTEDVALUE:
        //TODO
    case ASSERTSELECTEDVALUES:
        //TODO
    case ASSERTSOMETHINGSELECTED:
        //TODO
    case ASSERTSPEED:
        //TODO
    case ASSERTTABLE:
        //TODO
    case ASSERTTEXT:
        return com.assertEquals(driver.findElement(loc.locatorAsString(target)).getText(), value);
    case ASSERTTEXTNOTPRESENT:
        testData += "assertFalse(isElementPresent(\"//*[contains(, '" + value + "')]\"));";
        //TODO
    case ASSERTTEXTPRESENT:
        //TODO
    case ASSERTTITLE:
        return com.assertEquals(driver.findElement(loc.locatorAsString("tag=title")).getText(), value);
    case ASSERTVALUE:
        return com.assertEquals(value, driver.findElement(loc.locatorAsString(target)).getAttribute("value"));
    case ASSERTVISIBLE:
        return com.assertTrue(driver.findElement(loc.locatorAsString(target)).isDisplayed());
    case ASSERTWHETHERTHISFRAMEMATCHEFRAMEEXPRESSION:
        //TODO
    case ASSERTWHETHERTHISWINDOWMATCHEWINDOWEXPRESSION:
        //TODO
    case ASSERTXPATHCOUNT:
        return com.assertEquals(value, driver.findElements(loc.locatorAsString(target)).size());
    case ASSIGNID:
    case ASSIGNIDANDWAIT:
        return createWebElement(value, driver.findElement(loc.locatorAsString(target)).toString());
    case CAPTUREENTIREPAGESCREENSHOT:
    case CAPTUREENTIREPAGESCREENSHOTANDWAIT:
        return ebselen.window().takeScreenshot();
    case CHECK:
    case CHECKANDWAIT:
        return ebselen.element().check(target);
    case CHOOSECANCELONNEXTCONFIRMATION:
        //                return driver.switchTo().alert().dismiss();
        //TODO
    case CHOOSEOKONNEXTCONFIRMATION:
    case CHOOSEOKONNEXTCONFIRMATIONANDWAIT:
        //                return driver.switchTo().alert().accept();
        //TODO
    case CLICK:
    case CLICKANDWAIT:
        return driver.findElement(loc.locatorAsString(target)).click();
    case CLICKAT:
    case CLICKATANDWAIT:
        action.mouse().click(coords(value, target));
    case CLOSE:
        return driver.close();
    case CONTEXTMENU:
    case CONTEXTMENUANDWAIT:
        return action.mouse().contextClick(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case CONTEXTMENUAT:
    case CONTEXTMENUATANDWAIT:
        return action.mouse().contextClick(coords(value, target));
    case CREATECOOKIE:
    case CREATECOOKIEANDWAIT:
        //                driver.manage().addCookie()
        //TODO
    case DELETEALLVISIBLECOOKIES:
    case DELETEALLVISIBLECOOKIESANDWAIT:
        return driver.manage().deleteAllCookies();
    case DELETECOOKIE:
    case DELETECOOKIEANDWAIT:
        return driver.manage().deleteCookieNamed(target);
    case DESELECTPOPUP:
    case DESELECTPOPUPANDWAIT:
        return driver.switchTo().defaultContent();
    case DOUBLECLICK:
    case DOUBLECLICKANDWAIT:
        return action.mouse().doubleClick(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case DOUBLECLICKAT:
    case DOUBLECLICKATANDWAIT:
        return action.mouse().doubleClick(coords(value, target));
    case DRAGDROP:
    case DRAGANDDROP:
    case DRAGDROPANDWAIT:
    case DRAGANDDROPANDWAIT:
        String[] dragAndDropCoords = value.split(",", 1);
        String dragAndDropX = driver.findElement(loc.locatorAsString(target)).getLocation().getX() + "+"
                + dragAndDropCoords[0];
        String dragAndDropY = driver.findElement(loc.locatorAsString(target)).getLocation().getY() + "+"
                + dragAndDropCoords[1];
        //            return action.builder().clickAndHold(driver.findElement(loc.locatorAsString(target)))
        //                    .moveByOffset(Integer.parseInt(coords[0]), Integer.parseInt(coords[1])).click();";
        //TODO
    case DRAGANDDROPTOOBJECT:
    case DRAGANDDROPTOOBJECTANDWAIT:
        testData += "coords = value.split(\",\");" + "builder.clickAndHold(driver.findElement("
                + loc.locatorAsString(target)
                + ")).moveByOffset(Integer.parseInt(coords[0]), Integer.parseInt(coords[1])).release(driver.findElement("
                + loc.locatorAsString(value) + "));";
        //TODO
    case ECHO:
        return "LOGGER.info(\"{}\", " + value + ");";
    case FIREEVENT:
    case FIREEVENTANDWAIT:
        return ebselen.javascript().triggerJavascriptEvent(value,
                driver.findElement(loc.locatorAsString(target)).toString());
    case FOCUS:
    case FOCUSANDWAIT:
        //TODO focus on the element found below
        //((Locatable) driver.findElement(" + loc.locatorAsString(target) + ")).getLocationOnScreenOnceScrolledIntoView();
    case GOBACK:
    case GOBACKANDWAIT:
        return driver.navigate().back();
    case HIGHLIGHT:
    case HIGHLIGHTANDWAIT:
        //TODO
    case IGNOREATTRIBUTESWITHOUTVALUE:
    case IGNOREATTRIBUTESWITHOUTVALUEANDWAIT:
        //TODO
    case KEYDOWN:
    case KEYDOWNANDWAIT:
        return action.builder().keyDown(driver.findElement(loc.locatorAsString(target)).toString(),
                Keys.valueOf(value));
    case KEYPRESS:
    case KEYPRESSANDWAIT:
        return driver.findElement(loc.locatorAsString(target)).sendKeys(value);
    case KEYUP:
    case KEYUPANDWAIT:
        return action.builder().keyUp(driver.findElement(loc.locatorAsString(target)).toString(),
                Keys.valueOf(value));
    case METAKEYDOWN:
    case METAKEYDOWNANDWAIT:
        return action.builder().keyDown(driver.findElement(loc.locatorAsString(target)).toString(), Keys.META);
    case METAKEYUP:
    case METAKEYUPANDWAIT:
        return action.builder().keyUp(driver.findElement(loc.locatorAsString(target)).toString(), Keys.META);
    case MOUSEDOWN:
    case MOUSEDOWNANDWAIT:
        return action.mouse().mouseDown(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case MOUSEDOWNAT:
    case MOUSEDOWNATANDWAIT:
        return action.mouse().mouseDown(coords(value, target));
    case MOUSEDOWNRIGHT:
    case MOUSEDOWNRIGHTANDWAIT:
        //return action.mouse().("(Coordinates)" + driver.findElement(loc.locatorAsString(target)).getLocation());
        //TODO likemousedown but with context
    case MOUSEDOWNRIGHTAT:
    case MOUSEDOWNRIGHTATANDWAIT:
        //TODO
    case MOUSEMOVE:
    case MOUSEMOVEANDWAIT:
        return action.mouse().mouseMove(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case MOUSEMOVEAT:
    case MOUSEMOVEATANDWAIT:
        return action.mouse().mouseMove(coords(value, target));
    case MOUSEOUT:
    case MOUSEOUTANDWAIT:
        //TODO
    case MOUSEOVER:
    case MOUSEOVERANDWAIT:
        return action.mouse().mouseMove(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case MOUSEUP:
    case MOUSEUPANDWAIT:
        return action.mouse().mouseUp(
                returnCoordinates(driver.findElement(loc.locatorAsString(target)).getLocation().toString()));
    case MOUSEUPAT:
    case MOUSEUPATANDWAIT:
        return action.mouse().mouseUp(coords(value, target));
    case MOUSEUPRIGHT:
    case MOUSEUPRIGHTANDWAIT:
        //TODO
    case MOUSEUPRIGHTAT:
    case MOUSEUPRIGHTATANDWAIT:
        //TODO
    case OPEN:
        return driver.get(target);
    case OPENWINDOW:
    case OPENWINDOWANDWAIT:
        //TODO
    case PAUSE:
        return "Thread.sleep((long) Integer.parseInt(" + value + "));";
    case REFRESH:
    case REFRESHANDWAIT:
        return driver.navigate().refresh();
    case REMOVEALLSELECTIONS:
    case REMOVEALLSELECTIONSANDWAIT:
        return select.deselectAll(target);
    case REMOVESCRIPT:
    case REMOVESCRIPTANDWAIT:
        //TODO
    case REMOVESELECTION:
    case REMOVESELECTIONANDWAIT:
        return select.deselectByVisibleText(target, value);
    case ROLLUP:
    case ROLLUPANDWAIT:
        //TODO
    case RUNSCRIPT:
    case RUNSCRIPTANDWAIT:
        //TODO
    case SELECT:
    case SELECTANDWAIT:
        return select.selectByVisibleText(target, value);
    case SELECTFRAME:
        return driver.switchTo().frame(driver.findElement(loc.locatorAsString(target)).toString());
    case SELECTPOPUP:
    case SELECTPOPUPANDWAIT:
        //TODO
    case SELECTWINDOW:
        //TODO
    case SETBROWSERLOGLEVEL:
    case SETBROWSERLOGLEVELANDWAIT:
        return "LOGGER.warn(\"Modifying the Log Level mid test is not supported!\")";
    case SETMOUSESPEED:
    case SETMOUSESPEEDANDWAIT:
        //TODO
    case SETSPEED:
    case SETSPEEDANDWAIT:
        //TODO
    case SETTIMEOUT:
        return driver.manage().timeouts().setScriptTimeout(Long.parseLong(value), TimeUnit.MILLISECONDS);
    case SHIFTKEYDOWN:
    case SHIFTKEYDOWNANDWAIT:
        return action.keyboard().pressKey(Keys.SHIFT);
    case SHIFTKEYUP:
    case SHIFTKEYUPANDWAIT:
        return action.keyboard().releaseKey(Keys.SHIFT);
    case STORE:
        return store(value, target);
    case STOREALERT:
        return store(value, driver.switchTo().alert().getText());
    case STOREALERTPRESENT:
        testData += "boolean alertVisible = false;" + "try {" + "driver.switchTo().alert();"
                + "alertVisible = true;" + "} catch (Exception Ex) {" + "//Alert doesn't exist" + "}"
                + "storedVariables.put(" + value + ", alertVisible);";
        //TODO
    case STOREALLBUTTONS:
        //TODO check implementation...  The IDE implementation stores ID's, not Elements
        return store(value,
                driver.findElements(loc.locatorAsString("(//input[@type='button'])|(//button)")).toString());
    case STOREALLFIELDS:
        //TODO check implementation...  The IDE implementation stores ID's, not Elements
        //TODO check if this should just be input[@type='text'] or textarea as well?
        return store(value, driver.findElements(loc.locatorAsString("//input[@type='text']")).toString());
    case STOREALLLINKS:
        //TODO check implementation...  The IDE implementation stores ID's, not Elements
        return store(value, driver.findElements(loc.locatorAsString("tag=a")).toString());
    case STOREALLWINDOWIDS:
    case STOREALLWINDOWNAMES:
    case STOREALLWINDOWTITLES:
        return store(value, driver.getWindowHandles());
    case STOREATTRIBUTE:
        String[] locatorDetails = target.split("@", 1);
        return store(value,
                driver.findElement(loc.locatorAsString(locatorDetails[0])).getAttribute(locatorDetails[1]));
    case STOREATTRIBUTEFROMALLWINDOWS:
        //TODO
    case STOREBODYTEXT:
        return store(value, driver.findElement(loc.locatorAsString("tag=body")).getText());
    case STORECHECKED:
        return store(value, ebselen.element().isChecked(target));
    case STORECONFIRMATION:
        //TODO
    case STORECONFIRMATIONPRESENT:
        //TODO
    case STORECOOKIE:
        //TODO
    case STORECOOKIEBYNAME:
        //TODO
    case STORECOOKIEPRSENT:
        //TODO
    case STORECSSCOUNT:
        return store(value, driver.findElements(loc.locatorAsString(target)).size());
    case STORECURSORPOSITION:
        //TODO
    case STOREEDITABLE:
        return store(value, driver.findElement(loc.locatorAsString(target)).isEnabled());
    case STOREELEMENTHEIGHT:
        return store(value, driver.findElement(loc.locatorAsString(target)).getSize().getHeight());
    case STOREELEMENTINDEX:
        //TODO
    case STOREELEMENTPOSITIONLEFT:
        //TODO
    case STOREELEMENTPOSITIONTOP:
        //TODO
    case STOREELEMENTPRESENT:
        return store(value, ebselen.element().doesElementExist(loc.locatorAsString(target)));
    case STOREELEMENTWIDTH:
        return store(value, driver.findElement(loc.locatorAsString(target)).getSize().getWidth());
    case STOREEVAL:
        //TODO
    case STOREEXPRESSION:
        //TODO
    case STOREHTMLSOURCE:
        return store(value, driver.getPageSource());
    case STORELOCATION:
        return store(value, driver.getCurrentUrl());
    case STOREMOUSESPEED:
        //TODO
    case STOREORDERED:
        //TODO
    case STOREPROMPT:
        //TODO
    case STOREPROMPTPRESENT:
        //TODO
    case STORESELECTOPTIONS:
        //TODO
    case STORESELECTEDID:
        //TODO
    case STORESELECTEDIDS:
        //TODO
    case STORESELECTEDINDEX:
        //TODO
    case STORESELECTEDINDEXES:
        //TODO
    case STORESELECTEDLABEL:
        //TODO
    case STORESELECTEDLABELS:
        //TODO
    case STORESELECTEDVALUE:
        //TODO
    case STORESELECTEDVALUES:
        //TODO
    case STORESOMETHINGSELECTED:
        //TODO
    case STORESPEED:
        //TODO
    case STORETABLE:
        //TODO
    case STORETEXT:
        //TODO
    case STORETEXTPRESENT:
        //TODO
    case STORETITLE:
        //TODO
    case STOREVALUE:
        //TODO
    case STOREVISIBLE:
        //TODO
    case STOREWHETHERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case STOREWHETHERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case STOREXPATHCOUNT:
        return store(value, driver.findElements(loc.locatorAsString(target)).size());
    case SUBMIT:
    case SUBMITANDWAIT:
        driver.findElement(loc.locatorAsString(target)).submit();
    case TYPE:
    case TYPEANDWAIT:
    case TYPEKEYS:
    case TYPEKEYSANDWAIT:
        return driver.findElement(loc.locatorAsString(target)).sendKeys(value);
    case UNCHECK:
    case UNCHECKANDWAIT:
        return ebselen.element().uncheck(target);
    case USEXPATHLIBRARY:
    case USEXPATHLIBRARYANDWAIT:
        //TODO
    case VERIFYALERT:
        return com.verifyEquals(driver.switchTo().alert().getText(), value);
    case VERIFYALERTNOTPRESENT:
        //TODO
    case VERIFYALERTPRESENT:
        //TODO
    case VERIFYALLBUTTONS:
        //TODO
    case VERIFYALLFIELDS:
        //TODO
    case VERIFYALLLINKS:
        //TODO
    case VERIFYALLWINDOWIDS:
        //TODO
    case VERIFYALLWINDOWNAMES:
        //TODO
    case VERIFYALLWINDOWTITLES:
        //TODO
    case VERIFYATTRIBUTE:
        //TODO
    case VERIFYATTRIBUTEFROMALLWINDOWS:
        //TODO
    case VERIFYBODYTEXT:
        //TODO
    case VERIFYCHECKED:
        return com.verifyTrue(com.assertFalse(ebselen.element().isChecked(target)));
    case VERIFYCONFIRMATION:
        //TODO
    case VERIFYCONFIRMATIONNOTPRESENT:
        //TODO
    case VERIFYCONFIRMATIONPRESENT:
        //TODO
    case VERIFYCOOKIE:
        //TODO
    case VERIFYCOOKIEBYNAME:
        //TODO
    case VERIFYCOOKIENOTPRESENT:
        //TODO
    case VERIFYCOOKIEPRESENT:
        //TODO
    case VERIFYCSSCOUNT:
        return com.verifyEquals(driver.findElements(loc.locatorAsString(target)).size(), value);
    case VERIFYCURSORPOSITION:
        //TODO
    case VERIFYEDITABLE:
        return com.verifyTrue(driver.findElement(loc.locatorAsString(target)).isEnabled());
    case VERIFYELEMENTHEIGHT:
        return com.verifyEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("height"), value);
    case VERIFYELEMENTINDEX:
        //TODO
    case VERIFYELEMENTNOTPRESENT:
        return com.verifyFalse(ebselen.element().doesElementExist(loc.locatorAsString(target)));
    case VERIFYELEMENTPOSITIONLEFT:
        //TODO
    case VERIFYELEMENTPOSITIONTOP:
        //TODO
    case VERIFYELEMENTPRESENT:
        return com.verifyTrue(ebselen.element().doesElementExist(loc.locatorAsString(target)));
    case VERIFYELEMENTWIDTH:
        return com.verifyEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("width"), value);
    case VERIFYEVAL:
        //TODO
    case VERIFYEXPRESSION:
        //TODO
    case VERIFYHTMLSOURCE:
        //TODO
    case VERIFYLOCATION:
        //TODO
    case VERIFYMOUSESPEED:
        //TODO
    case VERIFYNOTALERT:
        //TODO
    case VERIFYNOTALLBUTTONS:
        //TODO
    case VERIFYNOTALLFIELDS:
        //TODO
    case VERIFYNOTALLLINKS:
        //TODO
    case VERIFYNOTALLWINDOWIDS:
        //TODO
    case VERIFYNOTALLWINDOWNAMES:
        //TODO
    case VERIFYNOTALLWINDOWTITLES:
        //TODO
    case VERIFYNOTATTRIBUTE:
        //TODO
    case VERIFYNOTATTRIBUTEFROMALLWINDOWS:
        //TODO
    case VERIFYNOTBODYTEXT:
        //TODO
    case VERIFYNOTCHECKED:
        return com.verifyFalse(com.assertFalse(ebselen.element().isChecked(target)));
    case VERIFYNOTCONFIRMATION:
        //TODO
    case VERIFYNOTCOOKIE:
        //TODO
    case VERIFYNOTCOOKIEBYNAME:
        //TODO
    case VERIFYNOTCSSCOUNT:
        return com.verifyNotEquals(driver.findElements(loc.locatorAsString(target)).size(), value);
    case VERIFYNOTCURSORPOSITION:
        //TODO
    case VERIFYNOTEDITABLE:
        return com.verifyFalse(driver.findElement(loc.locatorAsString(target)).isEnabled());
    case VERIFYNOTELEMENTHEIGHT:
        return com.verifyNotEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("height"),
                value);
    case VERIFYNOTELEMENTINDEX:
        //TODO
    case VERIFYNOTELEMENTPOSITIONLEFT:
        //TODO
    case VERIFYNOTELEMENTPOSITIONTOP:
        //TODO
    case VERIFYNOTELEMENTWIDTH:
        return com.verifyNotEquals(driver.findElement(loc.locatorAsString(target)).getCssValue("width"), value);
    case VERIFYNOTEVAL:
        //TODO
    case VERIFYNOTEXPRESSION:
        //TODO
    case VERIFYNOTHTMLSOURCE:
        //TODO
    case VERIFYNOTLOCATION:
        //TODO
    case VERIFYNOTMOUSESPEED:
        //TODO
    case VERIFYNOTORDERED:
        //TODO
    case VERIFYNOTPROMPT:
        //TODO
    case VERIFYNOTSELECTOPTIONS:
        //TODO
    case VERIFYNOTSELECTEDID:
        //TODO
    case VERIFYNOTSELECTEDIDS:
        //TODO
    case VERIFYNOTSELECTEDINDEX:
        //TODO
    case VERIFYNOTSELECTEDINDEXES:
        //TODO
    case VERIFYNOTSELECTEDLABEL:
        //TODO
    case VERIFYNOTSELECTEDLABELS:
        //TODO
    case VERIFYNOTSELECTEDVALUE:
        //TODO
    case VERIFYNOTSELECTEDVALUES:
        //TODO
    case VERIFYNOTSOMTHINGSELECTED:
        //TODO
    case VERIFYNOTSPEED:
        //TODO
    case VERIFYNOTTABLE:
        //TODO
    case VERIFYNOTTEXT:
        //TODO
    case VERIFYNOTTITLE:
        //TODO
    case VERIFYNOTVALUE:
        //TODO
    case VERIFYNOTVISIBLE:
        //TODO
    case VERIFYNOTWHETHERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case VERIFYNOTWHETHERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case VERIFYNOTXPATHCOUNT:
        return com.verifyNotEquals(value, driver.findElements(loc.locatorAsString(target)).size());
    case VERIFYORDERED:
        //TODO
    case VERIFYPROMPT:
        //TODO
    case VERIFYPROMPTNOTPRESENT:
        //TODO
    case VERIFYPROMPTPRESENT:
        //TODO
    case VERIFYSELECTOPTIONS:
        //TODO
    case VERIFYSELECTEDID:
        //TODO
    case VERIFYSELECTEDIDS:
        //TODO
    case VERIFYSELECTEDINDEX:
        //TODO
    case VERIFYSELECTEDINDEXES:
        //TODO
    case VERIFYSELECTEDLABEL:
        //TODO
    case VERIFYSELECTEDLABELS:
        //TODO
    case VERIFYSELECTEDVALUE:
        //TODO
    case VERIFYSELECTEDVALUES:
        //TODO
    case VERIFYSOMETHINGSELECTED:
        //TODO
    case VERIFYSPEED:
        //TODO
    case VERIFYTABLE:
        //TODO
    case VERIFYTEXT:
        //TODO
    case VERIFYTEXTNOTPRESENT:
        return com.verifyFalse(
                ebselen.element().doesElementExist(loc.locatorAsString("//*[contains(, '" + value + "')]")));
    case VERIFYTEXTPRESENT:
        return com.verifyTrue(
                ebselen.element().doesElementExist(loc.locatorAsString("//*[contains(, '" + value + "')]")));
    case VERIFYTITLE:
        //TODO
    case VERIFYVALUE:
        //TODO
    case VERIFYVISIBLE:
        //TODO
    case VERIFYWHETHERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case VERIFYWHETHERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case VERIFYXPATHCOUNT:
        return com.verifyEquals(value, driver.findElements(loc.locatorAsString(target)).size());
    case WAITFORALERT:
        //TODO
    case WAITFORALERTNOTPRESENT:
        //TODO
    case WAITFORALERTPRESENT:
        //TODO
    case WAITFORALLBUTTONS:
        //TODO
    case WAITFORALLFIELDS:
        //TODO
    case WAITFORALLLINKS:
        //TODO
    case WAITFORALLWINDOWIDS:
        //TODO
    case WAITFORALLWINDOWNAMES:
        //TODO
    case WAITFORALLWINDOWTITLES:
        //TODO
    case WAITFORATTRIBUTE:
        //TODO
    case WAITFORATTRIBUTEFROMALLWINDOWS:
        //TODO
    case WAITFORBODYTEXT:
        //TODO
    case WAITFORCHECKED:
        //TODO
    case WAITFORCONDITION:
        //TODO
    case WAITFORCONFIRMATION:
        //TODO
    case WAITFORCONFIRMATIONNOTPRESENT:
        //TODO
    case WAITFORCONFIRMATIONPRESENT:
        //TODO
    case WAITFORCOOKIE:
        //TODO
    case WAITFORCOOKIEBYNAME:
        //TODO
    case WAITFORCOOKIENOTPRESENT:
        //TODO
    case WAITFORCOOKIEPRESENT:
        //TODO
    case WAITFORCSSCOUNT:
        //TODO
    case WAITFORCURSORPOSITION:
        //TODO
    case WAITFOREDITABLE:
        //TODO
    case WAITFORELEMENTHEIGHT:
        //TODO
    case WAITFORELEMENTINDEX:
        //TODO
    case WAITFORELEMENTNOTPRESENT:
        //TODO
    case WAITFORELEMENTPOSITIONLEFT:
        //TODO
    case WAITFORELEMENTPOSITIONTOP:
        //TODO
    case WAITFORELEMENTPRESENT:
        //TODO
    case WAITFORELEMENTWIDTH:
        //TODO
    case WAITFOREVAL:
        //TODO
    case WAITFOREXPRESSION:
        //TODO
    case WAITFORFRAMETOLOAD:
        //TODO
    case WAITFORHTMLSOURCE:
        //TODO
    case WAITFORLOCATION:
        //TODO
    case WAITFORMOUSESPEED:
        //TODO
    case WAITFORNOTALERT:
        //TODO
    case WAITFORNOTALLBUTTONS:
        //TODO
    case WAITFORNOTALLFIELDS:
        //TODO
    case WAITFORNOTALLLINKS:
        //TODO
    case WAITFORNOTALLWINDOWIDS:
        //TODO
    case WAITFORNOTALLWINDOWNAMES:
        //TODO
    case WAITFORNOTALLWINDOWTITLES:
        //TODO
    case WAITFORNOTATTRIBUTE:
        //TODO
    case WAITFORNOTATTRIBUTEFROMALLWINDOWS:
        //TODO
    case WAITFORNOTBODYTEXT:
        //TODO
    case WAITFORNOTCHECKED:
        //TODO
    case WAITFORNOTCONFIRMATION:
        //TODO
    case WAITFORNOTCOOKIE:
        //TODO
    case WAITFORNOTCOOKIEBYNAME:
        //TODO
    case WAITFORNOTCSSCOUNT:
        //TODO
    case WAITFORNOTCURSORPOSITION:
        //TODO
    case WAITFORNOTEDITABLE:
        //TODO
    case WAITFORNOTELEMENTHEIGHT:
        //TODO
    case WAITFORNOTELEMENTINDEX:
        //TODO
    case WAITFORNOTELEMENTPOSITIONLEFT:
        //TODO
    case WAITFORNOTELEMENTPOSITIONTOP:
        //TODO
    case WAITFORNOTELEMENTWIDTH:
        //TODO
    case WAITFORNOTEVAL:
        //TODO
    case WAITFORNOTEXPRESSION:
        //TODO
    case WAITFORNOTHTMLSOURCE:
        //TODO
    case WAITFORNOTLOCATION:
        //TODO
    case WAITFORNOTMOUSESPEED:
        //TODO
    case WAITFORNOTORDERED:
        //TODO
    case WAITFORNOTPROMPT:
        //TODO
    case WAITFORNOTSELECTOPTIONS:
        //TODO
    case WAITFORNOTSELECTEDID:
        //TODO
    case WAITFORNOTSELECTEDIDS:
        //TODO
    case WAITFORNOTSELECTEDINDEX:
        //TODO
    case WAITFORNOTSELECTEDINDEXES:
        //TODO
    case WAITFORNOTSELECTEDLABEL:
        //TODO
    case WAITFORNOTSELECTEDLABELS:
        //TODO
    case WAITFORNOTSELECTEDVALUE:
        //TODO
    case WAITFORNOTSELECTEDVALUES:
        //TODO
    case WAITFORNOTSOMETHINGSELECTED:
        //TODO
    case WAITFORNOTSPEED:
        //TODO
    case WAITFORNOTTABLE:
        //TODO
    case WAITFORNOTTEXT:
        //TODO
    case WAITFORNOTTITLE:
        //TODO
    case WAITFORNOTVALUE:
        //TODO
    case WAITFORNOTVISIBLE:
        //TODO
    case WAITFORNOTWHETHERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case WAITFORNOTWHETHERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case WAITFORNOTXPATHCOUNT:
        //TODO
    case WAITFORORDERED:
        //TODO
    case WAITFORPAGETOLOAD:
        //TODO
    case WAITFORPOPUP:
        //TODO
    case WAITFORPROMPT:
        //TODO
    case WAITFORPROMPTNOTPRESENT:
        //TODO
    case WAITFORPROMPTPRESENT:
        //TODO
    case WAITFORSELECTOPTIONS:
        //TODO
    case WAITFORSELECTEDID:
        //TODO
    case WAITFORSELECTEDIDS:
        //TODO
    case WAITFORSELECTEDINDEX:
        //TODO
    case WAITFORSELECTEDINDEXES:
        //TODO
    case WAITFORSELECTEDLABEL:
        //TODO
    case WAITFORSELECTEDLABELS:
        //TODO
    case WAITFORSELECTEDVALUE:
        //TODO
    case WAITFORSELECTEDVALUES:
        //TODO
    case WAITFORSOMETHINGSELECTED:
        //TODO
    case WAITFORSPEED:
        //TODO
    case WAITFORTABLE:
        //TODO
    case WAITFORTEXT:
        //TODO
    case WAITFORTEXTNOTPRESENT:
        //TODO check implementation
        return ebselen.waiting().untilWebElement(loc.locatorAsString("//*[contains(., '" + target + "')]"))
                .doesNotExist();
    case WAITFORTEXTPRESENT:
        //TODO check implementation
        return ebselen.waiting().untilWebElement(loc.locatorAsString("//*[contains(., '" + target + "')]"))
                .exists();
    case WAITFORTITLE:

        //TODO
    case WAITFORVALUE:
        //wait for a value, returns value or on/off for checkbox/radio elements
        //TODO
    case WAITFORVISIBLE:
        //TODO
    case WAITFORWHETERTHISFRAMEMATCHFRAMEEXPRESSION:
        //TODO
    case WAITFORWHETERTHISWINDOWMATCHWINDOWEXPRESSION:
        //TODO
    case WAITFORXPATHCOUNT:
        //TODO
    case WINDOWFOCUS:
    case WINDOWFOCUSANDWAIT:
        //TODO
    case WINDOWMAXIMIZE:
    case WINDOWMAXIMIZEANDWAIT:
        //TODO
    default:
        throw new IDECommandNotFoundException();
    }
}

From source file:com.liferay.faces.test.alloy.showcase.datatable.DataTableTesterBase.java

License:Open Source License

/**
 * Must build this action using keyDown(key) and keyUp(key) since Action sendKeys behaves differently than
 * WebElement sendKeys (unless the browser is phantomjs, then it would need the following script).
 * https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Actions.html#sendKeys-java.lang.CharSequence...-
 *//* www.j a  v a2 s.c o  m*/
protected void metaOrCommandClick(BrowserDriver browserDriver, String xpath) {
    Keys metaOrCommandKey = Keys.META;

    if (System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac")) {
        metaOrCommandKey = Keys.COMMAND;
    }

    if ("phantomjs".equals(browserDriver.getBrowserName())) {
        browserDriver.executeScriptInCurrentWindow(
                "var element = arguments[0]; YUI().use('node-event-simulate', function(Y) { Y.one(element).simulate('click', { metaKey: true }); });",
                browserDriver.findElementByXpath(xpath));
    } else {
        Actions metaOrCommandClickBuilder = browserDriver.createActions();
        metaOrCommandClickBuilder.keyDown(metaOrCommandKey).click(browserDriver.findElementByXpath(xpath))
                .keyUp(metaOrCommandKey);

        Action metaOrCommandClick = metaOrCommandClickBuilder.build();
        metaOrCommandClick.perform();
    }
}

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;/* w w  w  . j  a va  2 s  .com*/
}

From source file:org.eclipse.scout.rt.testing.ui.rap.RapMock.java

License:Open Source License

@Override
public void pressKey(Key key) {
    switch (key) {
    case Shift:/*from   ww w.  j  a  v  a 2 s .  co m*/
        m_actionBuilder.keyDown(Keys.SHIFT);
        m_modifierPressed = true;
        break;
    case Control:
        m_actionBuilder.keyDown(Keys.CONTROL);
        //        m_bot.controlKeyDown();
        //        m_bot.keyDownNative("17");
        //        m_keyList.add(Keys.CONTROL);
        m_modifierPressed = true;
        break;
    case Alt:
        m_actionBuilder.keyDown(Keys.ALT);
        m_modifierPressed = true;
        break;
    case Windows:
        m_actionBuilder.keyDown(Keys.META);
        m_modifierPressed = true;
        break;
    default:
        m_actionBuilder.sendKeys(toSeleniumKey(key).toString());
        m_actionBuilder.perform();
        //        m_bot.keyDown(m_currentWidgetId, toSeleniumKey(key));
        waitForIdle();
        break;
    }
}

From source file:org.eclipse.scout.rt.testing.ui.rap.RapMock.java

License:Open Source License

@Override
public void releaseKey(Key key) {
    switch (key) {
    case Shift:/*from  w w  w  .  ja  va2s  . com*/
        m_actionBuilder.keyUp(Keys.SHIFT);
        m_modifierPressed = false;
        break;
    case Control:
        m_actionBuilder.keyUp(Keys.CONTROL);
        //        m_bot.controlKeyUp();
        //        m_bot.keyUpNative("17");
        //        getCurrentElement().sendKeys(m_keyList.toArray(new CharSequence[m_keyList.size()]));
        //        m_keyList.clear();

        //        getCurrentElement().sendKeys(Keys.CONTROL, "a");
        m_modifierPressed = false;
        break;
    case Alt:
        m_actionBuilder.keyUp(Keys.ALT);
        m_modifierPressed = false;
        break;
    case Windows:
        m_actionBuilder.keyUp(Keys.META);
        m_modifierPressed = false;
        break;
    default:
        m_actionBuilder.keyUp(toSeleniumKey(key));
        //        m_bot.keyUp(m_currentWidgetId, toSeleniumKey(key));
        break;
    }
    m_actionBuilder.perform();
    waitForIdle();
}

From source file:org.eclipse.scout.rt.testing.ui.rap.RapMock.java

License:Open Source License

protected Keys toSeleniumKey(Key key) {
    switch (key) {
    case Shift:// www.  j av a2 s.  c o m
        return Keys.SHIFT;
    case Control:
        return Keys.CONTROL;
    case Alt:
        return Keys.ALT;
    case Delete:
        return Keys.DELETE;
    case Backspace:
        return Keys.BACK_SPACE;
    case Enter:
        return Keys.ENTER;
    case Esc:
        return Keys.ESCAPE;
    case Tab:
        return Keys.TAB;
    case ContextMenu:
        throw new IllegalArgumentException("Unknown keyboard key: " + key);
    case Up:
        return Keys.UP;
    case Down:
        return Keys.DOWN;
    case Left:
        return Keys.LEFT;
    case Right:
        return Keys.RIGHT;
    case Windows:
        return Keys.META;
    case F1:
        return Keys.F1;
    case F2:
        return Keys.F2;
    case F3:
        return Keys.F3;
    case F4:
        return Keys.F4;
    case F5:
        return Keys.F5;
    case F6:
        return Keys.F6;
    case F7:
        return Keys.F7;
    case F8:
        return Keys.F8;
    case F9:
        return Keys.F9;
    case F10:
        return Keys.F10;
    case F11:
        return Keys.F11;
    case F12:
        return Keys.F12;
    case Home:
        return Keys.HOME;
    case End:
        return Keys.END;
    case PageUp:
        return Keys.PAGE_UP;
    case PageDown:
        return Keys.PAGE_DOWN;
    case NumPad0:
        return Keys.NUMPAD0;
    case NumPad1:
        return Keys.NUMPAD1;
    case NumPad2:
        return Keys.NUMPAD2;
    case NumPad3:
        return Keys.NUMPAD3;
    case NumPad4:
        return Keys.NUMPAD4;
    case NumPad5:
        return Keys.NUMPAD5;
    case NumPad6:
        return Keys.NUMPAD6;
    case NumPad7:
        return Keys.NUMPAD7;
    case NumPad8:
        return Keys.NUMPAD8;
    case NumPadMultiply:
        return Keys.MULTIPLY;
    case NumPadDivide:
        return Keys.DIVIDE;
    case NumPadAdd:
        return Keys.ADD;
    case NumPadSubtract:
        return Keys.SUBTRACT;
    case NumPadDecimal:
        return Keys.DECIMAL;
    case NumPadSeparator:
        return Keys.SEPARATOR;
    default:
        throw new IllegalArgumentException("Unknown keyboard key: " + key);
    }
}

From source file:org.safs.selenium.webdriver.lib.WDLibrary.java

License:Open Source License

/**
 * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum
 * @param keycode int, a java keycode//from   w  w w . j  av  a2s  . c o m
 * @return Keys enum for (primarily) non-printable (control) characters, or null.
 */
public static Keys convertToKeys(int keycode) {
    Keys key = null;
    switch (keycode) {
    case java.awt.event.KeyEvent.VK_ADD:
        key = Keys.ADD;
        break;
    case java.awt.event.KeyEvent.VK_ALT:
        key = Keys.ALT;
        break;
    case java.awt.event.KeyEvent.VK_KP_DOWN:
        key = Keys.ARROW_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_KP_LEFT:
        key = Keys.ARROW_LEFT;
        break;
    case java.awt.event.KeyEvent.VK_KP_RIGHT:
        key = Keys.ARROW_RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_KP_UP:
        key = Keys.ARROW_UP;
        break;
    case java.awt.event.KeyEvent.VK_BACK_SPACE:
        key = Keys.BACK_SPACE;
        break;
    case java.awt.event.KeyEvent.VK_CANCEL:
        key = Keys.CANCEL;
        break;
    case java.awt.event.KeyEvent.VK_CLEAR:
        key = Keys.CLEAR;
        break;
    case java.awt.event.KeyEvent.VK_WINDOWS:
        key = Keys.COMMAND;
        break;
    case java.awt.event.KeyEvent.VK_CONTROL:
        key = Keys.CONTROL;
        break;
    case java.awt.event.KeyEvent.VK_DECIMAL:
        key = Keys.DECIMAL;
        break;
    case java.awt.event.KeyEvent.VK_DELETE:
        key = Keys.DELETE;
        break;
    case java.awt.event.KeyEvent.VK_DIVIDE:
        key = Keys.DIVIDE;
        break;
    case java.awt.event.KeyEvent.VK_DOWN:
        key = Keys.DOWN;
        break;
    case java.awt.event.KeyEvent.VK_END:
        key = Keys.END;
        break;
    case java.awt.event.KeyEvent.VK_ENTER:
        key = Keys.ENTER;
        break;
    case java.awt.event.KeyEvent.VK_EQUALS:
        key = Keys.EQUALS;
        break;
    case java.awt.event.KeyEvent.VK_ESCAPE:
        key = Keys.ESCAPE;
        break;
    case java.awt.event.KeyEvent.VK_F1:
        key = Keys.F1;
        break;
    case java.awt.event.KeyEvent.VK_F2:
        key = Keys.F2;
        break;
    case java.awt.event.KeyEvent.VK_F3:
        key = Keys.F3;
        break;
    case java.awt.event.KeyEvent.VK_F4:
        key = Keys.F4;
        break;
    case java.awt.event.KeyEvent.VK_F5:
        key = Keys.F5;
        break;
    case java.awt.event.KeyEvent.VK_F6:
        key = Keys.F6;
        break;
    case java.awt.event.KeyEvent.VK_F7:
        key = Keys.F7;
        break;
    case java.awt.event.KeyEvent.VK_F8:
        key = Keys.F8;
        break;
    case java.awt.event.KeyEvent.VK_F9:
        key = Keys.F9;
        break;
    case java.awt.event.KeyEvent.VK_F10:
        key = Keys.F10;
        break;
    case java.awt.event.KeyEvent.VK_F11:
        key = Keys.F11;
        break;
    case java.awt.event.KeyEvent.VK_F12:
        key = Keys.F12;
        break;
    case java.awt.event.KeyEvent.VK_HELP:
        key = Keys.HELP;
        break;
    case java.awt.event.KeyEvent.VK_HOME:
        key = Keys.HOME;
        break;
    case java.awt.event.KeyEvent.VK_INSERT:
        key = Keys.INSERT;
        break;
    case java.awt.event.KeyEvent.VK_LEFT:
        key = Keys.LEFT;
        break;
    case java.awt.event.KeyEvent.VK_META:
        key = Keys.META;
        break;
    case java.awt.event.KeyEvent.VK_MULTIPLY:
        key = Keys.MULTIPLY;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD0:
        key = Keys.NUMPAD0;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD1:
        key = Keys.NUMPAD1;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD2:
        key = Keys.NUMPAD2;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD3:
        key = Keys.NUMPAD3;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD4:
        key = Keys.NUMPAD4;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD5:
        key = Keys.NUMPAD5;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD6:
        key = Keys.NUMPAD6;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD7:
        key = Keys.NUMPAD7;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD8:
        key = Keys.NUMPAD8;
        break;
    case java.awt.event.KeyEvent.VK_NUMPAD9:
        key = Keys.NUMPAD9;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_DOWN:
        key = Keys.PAGE_DOWN;
        break;
    case java.awt.event.KeyEvent.VK_PAGE_UP:
        key = Keys.PAGE_UP;
        break;
    case java.awt.event.KeyEvent.VK_PAUSE:
        key = Keys.PAUSE;
        break;
    case java.awt.event.KeyEvent.VK_RIGHT:
        key = Keys.RIGHT;
        break;
    case java.awt.event.KeyEvent.VK_SEMICOLON:
        key = Keys.SEMICOLON;
        break;
    case java.awt.event.KeyEvent.VK_SEPARATOR:
        key = Keys.SEPARATOR;
        break;
    case java.awt.event.KeyEvent.VK_SHIFT:
        key = Keys.SHIFT;
        break;
    case java.awt.event.KeyEvent.VK_SPACE:
        key = Keys.SPACE;
        break;
    case java.awt.event.KeyEvent.VK_SUBTRACT:
        key = Keys.SUBTRACT;
        break;
    case java.awt.event.KeyEvent.VK_TAB:
        key = Keys.TAB;
        break;
    case java.awt.event.KeyEvent.VK_UP:
        key = Keys.UP;
        break;
    }
    return key;
}

From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java

License:Open Source License

public void typeMetaEnter() {
    getRichTextArea().sendKeys(Keys.chord(Keys.META, Keys.RETURN));
}