List of usage examples for org.openqa.selenium Keys SHIFT
Keys SHIFT
To view the source code for org.openqa.selenium Keys SHIFT.
Click Source Link
From source file:org.safs.selenium.webdriver.CFComponent.java
License:Open Source License
/** <br><em>Purpose:</em> componentClick **/// w w w . jav a2 s . c om protected void componentClick() throws SAFSException { if (compObject == null) throw new SAFSException("Component WebElement is null."); try { java.awt.Point point = checkForCoord(iterator); String autoscroll = null; if (iterator.hasNext()) autoscroll = iterator.next(); long begin = System.currentTimeMillis(); if (action.equalsIgnoreCase(CLICK) || action.equalsIgnoreCase(COMPONENTCLICK)) { if (point == null) { WDLibrary.click(compObject, autoscroll); } else { WDLibrary.click(compObject, point, autoscroll); } } else if (action.equalsIgnoreCase(DOUBLECLICK)) { WDLibrary.doubleClick(compObject, point, autoscroll); } else if (action.equalsIgnoreCase(RIGHTCLICK)) { WDLibrary.rightclick(compObject, point, autoscroll); } else if (action.equalsIgnoreCase(CTRLCLICK)) { WDLibrary.click(compObject, point, Keys.CONTROL, WDLibrary.MOUSE_BUTTON_LEFT, autoscroll); } else if (action.equalsIgnoreCase(CTRLRIGHTCLICK)) { WDLibrary.click(compObject, point, Keys.CONTROL, WDLibrary.MOUSE_BUTTON_RIGHT, autoscroll); } else if (action.equalsIgnoreCase(SHIFTCLICK)) { WDLibrary.click(compObject, point, Keys.SHIFT, WDLibrary.MOUSE_BUTTON_LEFT, autoscroll); } long timeConsumed = System.currentTimeMillis() - begin; IndependantLog.debug("it took " + timeConsumed + " milliseconds or " + (timeConsumed / 1000) + " seconds to perform " + action); testRecordData.setStatusCode(StatusCodes.NO_SCRIPT_FAILURE); String msg = null; if (point != null) { Log.info("clicking point: " + point); String use = "X=" + String.valueOf(point.x) + " Y=" + String.valueOf(point.y); altText = windowName + ":" + compName + " " + action + " successful using " + use; msg = genericText.convert("success3a", altText, windowName, compName, action, use); } else { altText = windowName + ":" + compName + " " + action + " successful."; msg = genericText.convert("success3", altText, windowName, compName, action); } log.logMessage(testRecordData.getFac(), msg, PASSED_MESSAGE); } catch (Exception e) { String errormsg = StringUtils.debugmsg(e); IndependantLog.debug(action + " failed. Met Exception " + errormsg); issueErrorPerformingActionOnX(compName, errormsg); } }
From source file:org.safs.selenium.webdriver.CFListView.java
License:Open Source License
/** * process keywords who need at least one parameter; but it may be supplied with optional parameters. * @return boolean true if the keyword has been handled successfully;<br> * false if the keyword should not be handled in this method.<br> * @throws SeleniumPlusException if there are any problem during handling keyword. */// w ww .j a va2 s .c o m private boolean processWithOneRequiredParameter() throws SAFSException { String debugmsg = StringUtils.debugmsg(getClass(), "processWithOneRequiredParameter"); String requiredParam = (String) iterator.next(); TextMatchingCriterion criterion = null; //Handle optionl parameters int matchIndex = 1; String encoding = null; String variable = null; if (action.equalsIgnoreCase(ListViewFunctions.ACTIVATETEXTITEM_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.SELECTTEXTITEM_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.ACTIVATEPARTIALMATCH_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.SELECTPARTIALMATCH_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.ACTIVATEUNVERIFIEDTEXTITEM_KEYWORD) // ||action.equalsIgnoreCase(ListViewFunctions.VERIFYLISTCONTAINS_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.SELECTUNVERIFIEDTEXTITEM_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.RIGHTCLICKTEXTITEM_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.RIGHTCLICKUNVERIFIEDTEXTITEM_KEYWORD)) { //'matchIndex' optional parameter if (iterator.hasNext()) { IndependantLog.info(debugmsg + " command '" + action + "' retrieving optional matchIndex..."); matchIndex = StringUtilities.getIndex((String) iterator.next()); IndependantLog.info(debugmsg + " command '" + action + "' matchIndex: " + matchIndex); } } else if (action.equalsIgnoreCase(ListViewFunctions.CAPTUREITEMSTOFILE_KEYWORD)) { //'encoding' optional parameter if (iterator.hasNext()) { IndependantLog.info(debugmsg + " command '" + action + "' retrieving optional encoding..."); encoding = (String) iterator.next(); IndependantLog.info(debugmsg + " command '" + action + "' encoding: " + encoding); } } else if (action.equalsIgnoreCase(ListViewFunctions.SETLISTCONTAINS_KEYWORD)) { //'variable' optional parameter if (iterator.hasNext()) { IndependantLog.info(debugmsg + " command '" + action + "' retrieving optional variableName..."); variable = (String) iterator.next(); IndependantLog.info(debugmsg + " command '" + action + "' variableName: " + variable); } } matchIndex--;//convert 1-based index to 0-based index if (action.equalsIgnoreCase(ListViewFunctions.ACTIVATETEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.activateItem(criterion, true, null, null); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.selectItem(criterion, true); } else if (action.equalsIgnoreCase(ListViewFunctions.ACTIVATEPARTIALMATCH_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, true, matchIndex); listview.activateItem(criterion, false, null, null); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTPARTIALMATCH_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, true, matchIndex); listview.selectItem(criterion, false); } else if (action.equalsIgnoreCase(ListViewFunctions.ACTIVATEINDEX_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.ACTIVATEINDEXITEM_KEYWORD)) { int index = StringUtilities.getIndex(requiredParam); listview.activateItem(index, false, null, null); } else if (action.equalsIgnoreCase(ListViewFunctions.CLICKINDEX_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.CLICKINDEXITEM_KEYWORD)) { int index = StringUtilities.getIndex(requiredParam); listview.selectItem(index - 1, false); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTINDEX_KEYWORD) || action.equalsIgnoreCase(ListViewFunctions.SELECTINDEXITEM_KEYWORD)) { int index = StringUtilities.getIndex(requiredParam); listview.selectItem(index - 1, true); } else if (action.equalsIgnoreCase(ListViewFunctions.ACTIVATEUNVERIFIEDTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.activateItem(criterion, false, null, null); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTUNVERIFIEDTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.selectItem(criterion, false); } else if (action.equalsIgnoreCase(ListViewFunctions.VERIFYITEMUNSELECTED_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, TextMatchingCriterion.INDEX_TRY_ALL_MATCHED_ITEMS); listview.verifyItemSelection(criterion, false); } else if (action.equalsIgnoreCase(ListViewFunctions.VERIFYLISTCONTAINS_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.verifyContains(criterion); } else if (action.equalsIgnoreCase(ListViewFunctions.VERIFYSELECTEDITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, TextMatchingCriterion.INDEX_TRY_ALL_MATCHED_ITEMS); listview.verifyItemSelection(criterion, true); } else if (action.equalsIgnoreCase(ListViewFunctions.CAPTUREITEMSTOFILE_KEYWORD)) { Item[] items = listview.getContent(); try { String filename = deduceTestFile(requiredParam).getAbsolutePath(); IndependantLog.info(debugmsg + " filename='" + filename + "'; encoding='" + encoding + "'."); StringUtils.writeEncodingfile(filename, convertElementArrayToList(items), encoding); } catch (IOException e) { IndependantLog.error(debugmsg, e); throw new SAFSException("Fail to write file due to '" + e.getMessage() + "'"); } } else if (action.equalsIgnoreCase(ListViewFunctions.EXTENDSELECTIONTOTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, true, matchIndex); listview.selectItem(criterion, true, Keys.SHIFT, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTANOTHERPARTIALMATCH_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, true, matchIndex); listview.selectItem(criterion, true, Keys.CONTROL, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(ListViewFunctions.SELECTANOTHERTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.selectItem(criterion, true, Keys.CONTROL, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(ListViewFunctions.SETLISTCONTAINS_KEYWORD)) { try { criterion = new TextMatchingCriterion(requiredParam, false, 0); listview.verifyContains(criterion); setVariable(variable, Boolean.toString(true)); } catch (SeleniumPlusException se) { if (!SeleniumPlusException.CODE_VERIFICATION_FAIL.equals(se.getCode())) throw se; setVariable(variable, Boolean.toString(false)); } } else if (action.equalsIgnoreCase(ListViewFunctions.RIGHTCLICKTEXTITEM_KEYWORD)) { //TODO How to verify the right-click??? criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.selectItem(criterion, false, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); } else if (action.equalsIgnoreCase(ListViewFunctions.RIGHTCLICKUNVERIFIEDTEXTITEM_KEYWORD)) { criterion = new TextMatchingCriterion(requiredParam, false, matchIndex); listview.selectItem(criterion, false, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); } else { testRecordData.setStatusCode(StatusCodes.SCRIPT_NOT_EXECUTED); IndependantLog.warn(debugmsg + action + " could not be handled here."); return false; } return true; }
From source file:org.safs.selenium.webdriver.CFTree.java
License:Open Source License
@SuppressWarnings("deprecation") private boolean processWithOneRequiredParameter() throws SAFSException { String debugmsg = StringUtils.debugmsg(getClass(), "processWithOneRequiredParameter"); String requiredParam = (String) iterator.next(); //Handle optionl parameters int matchIndex = 1; String branch = null;// ww w .j a v a 2s. c om String indentMark = null; String encoding = null; if (action.equalsIgnoreCase(TreeViewFunctions.CLICKPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.CLICKTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.CLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.COLLAPSE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.COLLAPSEPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.COLLAPSETEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.COLLAPSEUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.CTRLCLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.EXPAND_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.EXPANDPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.EXPANDUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECT_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECTPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECTUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SHIFTCLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.VERIFYNODEUNSELECTED_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.VERIFYSELECTEDNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.VERIFYTREECONTAINSNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.VERIFYTREECONTAINSPARTIALMATCH_KEYWORD)) { //'matchIndex' optional parameter if (iterator.hasNext()) matchIndex = StringUtilities.getIndex((String) iterator.next()); } else if (action.equalsIgnoreCase(TreeViewFunctions.CAPTURETREEDATATOFILE_KEYWORD)) { //'encoding' optional parameter if (iterator.hasNext()) branch = (String) iterator.next(); if (iterator.hasNext()) indentMark = (String) iterator.next(); if (iterator.hasNext()) encoding = (String) iterator.next(); if (indentMark == null || indentMark.trim().isEmpty()) indentMark = INDENT_MARK; } matchIndex--;//convert 1-based index to 0-based index if (action.equalsIgnoreCase(TreeViewFunctions.CLICKPARTIAL_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECTPARTIAL_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, true, matchIndex), true, null, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(TreeViewFunctions.CLICKTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECT_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECTTEXTNODE_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), true, null, null, WDLibrary.MOUSE_BUTTON_LEFT); //tree.SelectTextNode(requiredParam);//used for keyword SELECTTEXTNODE_KEYWORD } else if (action.equalsIgnoreCase(TreeViewFunctions.CLICKUNVERIFIEDTEXTNODE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.SELECTUNVERIFIEDTEXTNODE_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, null, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(TreeViewFunctions.COLLAPSE_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.COLLAPSETEXTNODE_KEYWORD)) { tree.collapseItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, true); } else if (action.equalsIgnoreCase(TreeViewFunctions.COLLAPSEPARTIAL_KEYWORD)) { tree.collapseItem(new TextMatchingCriterion(requiredParam, true, matchIndex), false, true); } else if (action.equalsIgnoreCase(TreeViewFunctions.COLLAPSEUNVERIFIEDTEXTNODE_KEYWORD)) { tree.collapseItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, false); } else if (action.equalsIgnoreCase(TreeViewFunctions.CTRLCLICKUNVERIFIEDTEXTNODE_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, Keys.CONTROL, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKPARTIAL_KEYWORD)) { tree.activateItem(new TextMatchingCriterion(requiredParam, true, matchIndex), true, null, null); } else if (action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKTEXTNODE_KEYWORD)) { tree.activateItem(new TextMatchingCriterion(requiredParam, false, matchIndex), true, null, null); } else if (action.equalsIgnoreCase(TreeViewFunctions.DOUBLECLICKUNVERIFIEDTEXTNODE_KEYWORD)) { tree.activateItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, null, null); } else if (action.equalsIgnoreCase(TreeViewFunctions.EXPAND_KEYWORD) || action.equalsIgnoreCase(TreeViewFunctions.EXPANDTEXTNODE_KEYWORD)) { tree.expandItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, true); //tree.ExpandTextNode(requiredParam);//used for keyword EXPANDTEXTNODE_KEYWORD } else if (action.equalsIgnoreCase(TreeViewFunctions.EXPANDPARTIAL_KEYWORD)) { tree.expandItem(new TextMatchingCriterion(requiredParam, true, matchIndex), false, true); } else if (action.equalsIgnoreCase(TreeViewFunctions.EXPANDUNVERIFIEDTEXTNODE_KEYWORD)) { tree.expandItem(new TextMatchingCriterion(requiredParam, true, matchIndex), false, false); } else if (action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKPARTIAL_KEYWORD)) { // tree.selectItem(new TextMatchingCriterion(requiredParam, true, matchIndex), true, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); tree.selectItem(new TextMatchingCriterion(requiredParam, true, matchIndex), false, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); } else if (action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKTEXTNODE_KEYWORD)) { // tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), true, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); } else if (action.equalsIgnoreCase(TreeViewFunctions.RIGHTCLICKUNVERIFIEDTEXTNODE_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, null, null, WDLibrary.MOUSE_BUTTON_RIGHT); } else if (action.equalsIgnoreCase(TreeViewFunctions.SHIFTCLICKUNVERIFIEDTEXTNODE_KEYWORD)) { tree.selectItem(new TextMatchingCriterion(requiredParam, false, matchIndex), false, Keys.SHIFT, null, WDLibrary.MOUSE_BUTTON_LEFT); } else if (action.equalsIgnoreCase(TreeViewFunctions.VERIFYNODEUNSELECTED_KEYWORD)) { tree.verifyItemSelection(new TextMatchingCriterion(requiredParam, false, matchIndex), false); } else if (action.equalsIgnoreCase(TreeViewFunctions.VERIFYSELECTEDNODE_KEYWORD)) { tree.verifyItemSelection(new TextMatchingCriterion(requiredParam, false, matchIndex), true); } else if (action.equalsIgnoreCase(TreeViewFunctions.VERIFYTREECONTAINSNODE_KEYWORD)) { tree.verifyContains(new TextMatchingCriterion(requiredParam, false, matchIndex)); } else if (action.equalsIgnoreCase(TreeViewFunctions.VERIFYTREECONTAINSPARTIALMATCH_KEYWORD)) { tree.verifyContains(new TextMatchingCriterion(requiredParam, true, matchIndex)); } else if (action.equalsIgnoreCase(TreeViewFunctions.CAPTURETREEDATATOFILE_KEYWORD)) { TreeNode[] contents = null; if (branch == null || branch.isEmpty()) { contents = tree.getContent(); } else { //if branch contains value, find the correspond node. TreeNode node = tree.getMatchedElement(new TextMatchingCriterion(branch, false, 0)); contents = new TreeNode[1]; contents[0] = node; } BufferedWriter writer = null; try { //requiredParam is filename String filename = deduceTestFile(requiredParam).getAbsolutePath(); writer = FileUtilities.getBufferedFileWriter(filename, encoding); writeTreeNodesToFile(writer, contents, indentMark, 0); } catch (FileNotFoundException e) { throw new SeleniumPlusException("Can not find file '" + requiredParam + "'"); } finally { try { if (writer != null) writer.close(); } catch (IOException ignore) { } } } else { testRecordData.setStatusCode(StatusCodes.SCRIPT_NOT_EXECUTED); IndependantLog.warn(debugmsg + action + " could not be handled here."); return false; } return true; }
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 a va 2 s.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.safs.selenium.webdriver.lib.WDLibrary.java
License:Open Source License
/** * * @param key Keys, the selenium Keys value * @return int the value of java KeyEvent * @throws SeleniumPlusException//from w w w.j av a2s . c o m */ static int toJavaKeyCode(Keys key) throws SeleniumPlusException { String debugmsg = StringUtils.debugmsg(WDLibrary.class, "toJavaKeyCode"); if (Keys.SHIFT.equals(key)) return KeyEvent.VK_SHIFT; else if (Keys.LEFT_SHIFT.equals(key)) return KeyEvent.VK_SHIFT; else if (Keys.CONTROL.equals(key)) return KeyEvent.VK_CONTROL; else if (Keys.LEFT_CONTROL.equals(key)) return KeyEvent.VK_CONTROL; else if (Keys.ALT.equals(key)) return KeyEvent.VK_ALT; else if (Keys.LEFT_ALT.equals(key)) return KeyEvent.VK_ALT; else { String msg = " No handled key '" + (key == null ? "null" : key.toString()) + "'."; IndependantLog.debug(debugmsg + msg); throw new SeleniumPlusException(msg); } }
From source file:org.usapi.nodetypes.AbstractNode.java
License:Apache License
private void modifierKeyDown(int modifierKey) throws USAPIException { switch (modifierKey) { case ALT_KEY: getKeyboard().pressKey(Keys.ALT); break;// www. ja v a 2 s . c om case CTRL_KEY: getKeyboard().pressKey(Keys.CONTROL); break; case SHIFT_KEY: getKeyboard().pressKey(Keys.SHIFT); break; } }
From source file:org.usapi.nodetypes.AbstractNode.java
License:Apache License
private void modifierKeyUp(int modifierKey) throws USAPIException { switch (modifierKey) { case ALT_KEY: getKeyboard().releaseKey(Keys.ALT); break;//w ww . j ava2s .c o m case CTRL_KEY: getKeyboard().releaseKey(Keys.CONTROL); break; case SHIFT_KEY: getKeyboard().releaseKey(Keys.SHIFT); break; } }
From source file:org.xwiki.test.selenium.framework.AlbatrossSkinExecutor.java
License:Open Source License
public void typeShiftEnterInWysiwyg() { sendKeysToTinyMCE(Keys.chord(Keys.SHIFT, Keys.ENTER)); }
From source file:org.xwiki.test.selenium.WikiEditorTest.java
License:Open Source License
/** * Tests that the specified tool bar button works. * /* w w w .jav a2s. c o m*/ * @param buttonTitle the title of a tool bar button * @param format the format of the text inserted by the specified button * @param defaultText the default text inserted if there's no text selected in the text area */ private void testToolBarButton(String buttonTitle, String format, String defaultText) { editInWikiEditor(this.getClass().getSimpleName(), getTestMethodName(), SYNTAX); WebElement textArea = getDriver().findElement(By.id("content")); textArea.clear(); textArea.sendKeys("a"); String buttonLocator = "//img[@title = '" + buttonTitle + "']"; getSelenium().click(buttonLocator); // Type b and c on two different lines and move the caret after b. textArea.sendKeys("b", Keys.RETURN, "c", Keys.ARROW_LEFT, Keys.ARROW_LEFT); getSelenium().click(buttonLocator); // Move the caret after c, type d and e, then select d. textArea.sendKeys(Keys.PAGE_DOWN, Keys.END, "de", Keys.ARROW_LEFT, Keys.chord(Keys.SHIFT, Keys.ARROW_LEFT)); getSelenium().click(buttonLocator); if (defaultText.isEmpty()) { assertEquals("a" + format + "b" + format + "\nc" + format + "de", textArea.getAttribute("value")); } else { assertEquals(String.format("a" + format + "b" + format + "\nc" + format + "e", defaultText, defaultText, "d"), textArea.getAttribute("value")); } }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
public void typeShiftEnter() { getRichTextArea().sendKeys(Keys.chord(Keys.SHIFT, Keys.RETURN)); }