List of usage examples for org.openqa.selenium Keys chord
public static String chord(Iterable<CharSequence> value)
From source file:org.eclipse.che.selenium.pageobject.KeyBindings.java
License:Open Source License
/** * Waits the tag 'body' is loaded and enter key combination * * @param key is key combination/*from w ww . j ava 2 s .c o m*/ */ public void enterKeyCombination(Keys... key) { new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC) .until(ExpectedConditions.visibilityOfElementLocated(By.tagName("body"))).sendKeys(Keys.chord(key)); }
From source file:org.rstudio.studio.selenium.WorkbenchTests.java
License:Open Source License
@Test public void testWorkbenchPersistance() throws Exception { clearWorkspace();/*from www . j a va 2 s. co m*/ // Add a variable to the workspace (new Actions(driver_)).sendKeys(Keys.ESCAPE + "selenium <- function() { 42 }" + Keys.ENTER).perform(); // Save the workspace WebElement saveItem = MenuNavigator.getMenuItem(driver_, "Session", "Save Workspace As..."); saveItem.click(); WebElement saveDialog = DialogTestUtils.waitForModalToAppear(driver_); DialogTestUtils.waitForFocusedInput(driver_, saveDialog); File tempFile = File.createTempFile("rstudio-selenium-workspace-", ".RData"); String workspaceFilePath = tempFile.getAbsolutePath(); tempFile.delete(); (new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform(); DialogTestUtils.waitForModalToDisappear(driver_); // Clear the workspace and load it again clearWorkspace(); WebElement loadItem = MenuNavigator.getMenuItem(driver_, "Session", "Load Workspace..."); loadItem.click(); WebElement loadDialog = DialogTestUtils.waitForModalToAppear(driver_); DialogTestUtils.waitForFocusedInput(driver_, loadDialog); (new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform(); DialogTestUtils.waitForModalToDisappear(driver_); // List the workspace and see if the variable is present ConsoleTestUtils.beginConsoleInteraction(driver_); (new Actions(driver_)).sendKeys(Keys.chord(Keys.CONTROL + "l")).sendKeys(Keys.ESCAPE + "ls()" + Keys.ENTER) .perform(); ConsoleTestUtils.waitForConsoleContainsText(driver_, "selenium"); }
From source file:org.xframium.gesture.factory.spi.selenium.KeyPressGesture.java
License:Open Source License
@Override protected boolean _executeGesture(WebDriver webDriver) { String[] keyCodes = getKeyCode().split("\\+"); String keyPressed = null;// w ww . j a va2 s . c o m List<CharSequence> charSequence = new ArrayList<CharSequence>(); for (String keyCode : keyCodes) { if (Keys.valueOf(keyCode) != null) { charSequence.add(Keys.valueOf(keyCode.toUpperCase())); } else { throw new IllegalArgumentException("Unsupported KeyPressGesture Type " + keyCode); } } if (charSequence.size() > 0) { Iterable<CharSequence> iterable = charSequence; keyPressed = Keys.chord(iterable); new Actions(webDriver).moveToElement(webElement).sendKeys(keyPressed).perform(); } return true; }
From source file:org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase.java
License:Open Source License
/** * Presses the specified key for the given number of times in WYSIWYG rich text editor. * //w w w. j a v a 2 s . c om * @param key the key to be pressed * @param count the number of times to press the specified key * @param hold {@code false} if the key should be released after each key press, {@code true} if it should be hold * down and released just at the end */ public void sendKey(Keys key, int count, boolean hold) { Keys[] sequence = new Keys[count]; Arrays.fill(sequence, key); if (hold) { getRichTextArea().sendKeys(Keys.chord(sequence)); } else { getRichTextArea().sendKeys(sequence); } }