List of usage examples for org.openqa.selenium Keys chord
public static String chord(Iterable<CharSequence> value)
From source file:br.gov.frameworkdemoiselle.behave.runner.webdriver.ui.WebTextField.java
License:Open Source License
/** * O mtodo de limpar o campo do WebDriver no funciona corretamente com * campos com mscara. Segue abaixo o que esta escrito no javadoc do * Webdriver.//from w w w . j av a 2 s . com * * ------------------------------------------------------------------------ * If this element is a text entry element, this will clear the value. Has * no effect on other elements. Text entry elements are INPUT and TEXTAREA * elements. * * Note that the events fired by this event may not be as you'd expect. In * particular, we don't fire any keyboard or mouse events. If you want to * ensure keyboard events are fired, consider using something like * {@link #sendKeys(CharSequence...)} with the backspace key. To ensure you * get a change event, consider following with a call to * {@link #sendKeys(CharSequence...)} with the tab key. * ------------------------------------------------------------------------ */ public void clear() { waitElement(0); // Limpa o campo enviando BACKSPACE getElements().get(0).sendKeys(getValueToSend(Keys.chord(Keys.BACK_SPACE))); }
From source file:cat.calidos.morfeu.webapp.ui.UIWidget.java
License:Apache License
@SuppressWarnings("unchecked") public T pressKey(String k) { // we are sending the keys this way as it seems to work as it should, selenide or selenium has a lot of trouble here Actions actions = new Actions(driver); //actions.moveToElement(element.getWrappedElement()); //actions.click(); actions.sendKeys(Keys.chord((CharSequence) k)); actions.build().perform();/*from w ww . ja v a2 s.c o m*/ // this keeps failing randomly try { Thread.sleep(50); } catch (InterruptedException e) { } return (T) this; }
From source file:com.giri.target.svr.cmd.KeyCommandProcessor.java
License:Open Source License
public CharSequence getKey(String keystr) throws Exception { CharSequence keySeq = keystr; try {/*from ww w. j a v a 2 s . c o m*/ keySeq = Keys.valueOf(keystr); } catch (IllegalArgumentException e) { // looking for some short keys, // CTRL - CONTROL // DEL - DELETE //ESCAPE if (keystr.indexOf('+') != -1 && keystr.length() > 1) { String[] keyStrs = keystr.split("\\+"); StringBuilder sb = new StringBuilder(); if (keyStrs != null && keyStrs.length > 0) { // pass for number check CharSequence[] kf = new CharSequence[keyStrs.length]; int cnt = 0; for (String string : keyStrs) { CharSequence keys = getKey(string); keys = (keys == null ? string : keys); kf[cnt] = keys; if (cnt != 0) { sb.append(" + "); } // if(keys == null){ // throw new Exception("No such key '"+string+"'"); // } sb.append(keys); cnt++; } keySeq = Keys.chord(kf); } System.out.println("Multikeys [" + sb.toString() + "]: " + keySeq); } else if ("CTRL".equalsIgnoreCase(keystr)) { keySeq = Keys.CONTROL; } else if ("DEL".equalsIgnoreCase(keystr)) { keySeq = Keys.DELETE; } else if ("EQ".equalsIgnoreCase(keystr)) { keySeq = Keys.EQUALS; } else if ("ESC".equalsIgnoreCase(keystr)) { keySeq = Keys.ESCAPE; } else { // check if its number key try { int num = Integer.parseInt(keystr); if (num >= 0 && num <= 9) { keySeq = Keys.valueOf("NUMPAD" + num); } } catch (Exception e1) { } } } return keySeq; }
From source file:com.screenslicer.core.util.BrowserUtil.java
License:Open Source License
public static String newWindow(Browser browser, boolean cleanupWindows) throws ActionFailed { try {// w ww . j a v a 2 s . co m handleNewWindows(browser, browser.getWindowHandle(), cleanupWindows); Set<String> origHandles = new HashSet<String>(browser.getWindowHandles()); try { browser.getKeyboard().sendKeys(Keys.chord(Keys.CONTROL + "n")); } catch (Browser.Retry r) { throw r; } catch (Browser.Fatal f) { throw f; } catch (Throwable t) { Log.exception(t); } Collection<String> handles = new HashSet<String>(browser.getWindowHandles()); handles.removeAll(origHandles); if (!handles.isEmpty()) { browser.switchTo().window(handles.iterator().next()); } else { browser.executeScript("window.open('');"); handles = new HashSet<String>(browser.getWindowHandles()); handles.removeAll(origHandles); if (!handles.isEmpty()) { browser.switchTo().window(handles.iterator().next()); } } return browser.getWindowHandle(); } catch (Browser.Retry r) { throw r; } catch (Browser.Fatal f) { throw f; } catch (Throwable t) { throw new ActionFailed(t); } }
From source file:com.screenslicer.core.util.Util.java
License:Open Source License
public static String newWindow(RemoteWebDriver driver) throws ActionFailed { try {// w ww .ja v a 2 s . c om String origHandle = driver.getWindowHandle(); cleanUpNewWindows(driver, origHandle); try { driver.getKeyboard().sendKeys(Keys.chord(Keys.CONTROL + "n")); } catch (Throwable t) { Log.exception(t); } Util.driverSleepStartup(); Collection<String> handles = new HashSet<String>(driver.getWindowHandles()); handles.remove(origHandle); if (!handles.isEmpty()) { driver.switchTo().window(handles.iterator().next()); } else { driver.executeScript("window.open('');"); Util.driverSleepStartup(); handles = new HashSet<String>(driver.getWindowHandles()); handles.remove(origHandle); if (!handles.isEmpty()) { driver.switchTo().window(handles.iterator().next()); } } return driver.getWindowHandle(); } catch (Throwable t) { Log.exception(t); throw new ActionFailed(t); } }
From source file:com.vaadin.tests.components.orderedlayout.OrderedLayoutExpandTest.java
License:Apache License
private void openDebugExamineComponentHierarchyTab() { WebElement button = findElement(By.xpath("//button[@title='Examine component hierarchy']")); // can't use 'click()' with zoom levels other than 100% button.sendKeys(Keys.chord(Keys.SPACE)); }
From source file:com.vaadin.tests.components.orderedlayout.OrderedLayoutExpandTest.java
License:Apache License
private void clickDebugCheckLayoutsForPotentialProblems() { WebElement button = findElement(By.xpath("//button[@title='Check layouts for potential problems']")); button.sendKeys(Keys.chord(Keys.SPACE)); }
From source file:org.alfresco.po.share.site.document.EditHtmlDocumentPage.java
License:Open Source License
/** * Edit the editor, enter new text line, count the lines and save it. * /* w w w . j ava 2 s . c o m*/ * @param txtLine String */ public void editText(String txtLine) { try { driver.switchTo().frame(IFRAME_ID); WebElement element = findAndWait(By.cssSelector("#tinymce")); element.sendKeys(txtLine); element.sendKeys(Keys.chord(Keys.ENTER)); driver.switchTo().defaultContent(); } catch (TimeoutException toe) { logger.error("Tinymce Editor is not found", toe); } }
From source file:org.alfresco.po.share.site.document.EditHtmlDocumentPage.java
License:Open Source License
/** * Edit the editor, enter new text line, count the lines and save it. * * @param txtLine String//from w w w . ja va 2 s.c o m */ public void addTextToTinyMCE(String txtLine) { try { driver.switchTo().defaultContent(); TinyMceEditor tinyMceEditor = new TinyMceEditor(); tinyMceEditor.setTinyMce(); String oldText = tinyMceEditor.getContent(); tinyMceEditor.setText(oldText + txtLine); driver.switchTo().frame(IFRAME_ID); WebElement element = findAndWait(By.cssSelector("#tinymce")); element.sendKeys(Keys.chord(Keys.ENTER)); driver.switchTo().defaultContent(); } catch (TimeoutException toe) { logger.error("Tinymce Editor is not found", toe); } }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** Opens javadoc's popup */ public void openJavaDocPopUp() { loader.waitOnClosed();// w w w .j av a 2s . co m actionsFactory.createAction(seleniumWebDriver).keyDown(CONTROL).sendKeys(Keys.chord("q")).keyUp(CONTROL) .perform(); }