List of usage examples for org.openqa.selenium.interactions Actions keyUp
public Actions keyUp(CharSequence key)
From source file:com.pentaho.gui.web.puc.BrowseFiles.java
License:Apache License
/** * Given the path to a folder this method will delete all files located in that folder that contain a specific string * in the name/*from w w w.ja v a 2 s .co m*/ * * Ex. "/public/plugin-samples/pentaho-cdf-dd" the SelectFolder method will be called with the path provided, it it * returns false an info will be shown on the logs saying the file wasn't deleted for it wasn't found. * * If it returns true, all files containing string "name" provided in the name will be selected, Delete button will be * clicked on File Actions, it will wait for popup and confirm the delete action. * * @param path * @param name */ public void DeleteMultipleFilesByName(String path, String name) { LOG.debug("DeleteMultipleFilesByName::Enter"); if (SelectFolder(path)) { LOG.debug("Deleting [" + path + "] with name [" + name + "]"); WebElement elemWidgetFile = this.elemHelper.WaitForElementPresence(this.DRIVER, By.cssSelector("div[title='" + name + ".wcdf']"), 1); if (elemWidgetFile != null) { WebElement listFiles = this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.xpath("//div[@id='fileBrowserFiles']/div[2]")); List<WebElement> theNamedFiles = listFiles .findElements(By.xpath("//div[@class='title' and contains(text(),'" + name + "')]")); // Check if the widget named exist if (theNamedFiles != null) { if (theNamedFiles.size() > 0) { WebElement[] arraytheNamedFiles = new WebElement[theNamedFiles.size()]; theNamedFiles.toArray(arraytheNamedFiles); // Where we want to select three files // <the widget> // <the widget>.cdfde // <the widget>.component.xml // To do that we select each file (using the CONTROL key) and delete them. Actions action = new Actions(this.DRIVER); action.keyDown(Keys.CONTROL); for (WebElement arraytheNamedFile : arraytheNamedFiles) { action.click(arraytheNamedFile); } action.keyUp(Keys.CONTROL); action.build().perform(); // Here we still in the iframe assertNotNull(this.elemHelper.WaitForElementVisibility(this.DRIVER, By.id("deleteButton"))); this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("deleteButton")) .click(); // Go back to root html this.DRIVER.switchTo().defaultContent(); assertEquals( this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.cssSelector("div.gwt-HTML")).getText(), "Are you sure you want to move all selected items to the trash?"); this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("okButton")).click(); // wait for visibility of waiting pop-up this.elemHelper.WaitForElementInvisibility(this.DRIVER, By.xpath("//div[@class='busy-indicator-container waitPopup']")); assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("applicationShell"))); assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.xpath("//iframe[@id='browser.perspective']"))); this.DRIVER.switchTo().frame("browser.perspective"); assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.id("fileBrowser"))); this.elemHelper.WaitForElementInvisibility(this.DRIVER, By.xpath("//div[@class='spinner large-spinner']")); this.elemHelper.WaitForElementInvisibility(this.DRIVER, By.xpath("(//div[@class='spinner large-spinner'])[2]")); this.elemHelper.Click(this.DRIVER, By.id("refreshBrowserIcon")); this.elemHelper.WaitForElementInvisibility(this.DRIVER, By.xpath("//div[@class='spinner large-spinner']")); this.elemHelper.WaitForElementInvisibility(this.DRIVER, By.xpath("(//div[@class='spinner large-spinner'])[2]")); // Assert Panels assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.xpath("//div[@id='fileBrowserFolders']"))); assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.xpath("//div[@id='fileBrowserFiles']"))); assertNotNull(this.elemHelper.WaitForElementPresenceAndVisible(this.DRIVER, By.xpath("//div[@id='fileBrowserButtons']"))); LOG.info("Exit: Assert browser perspective shown"); } else { LOG.debug("No file exist!"); } } else { LOG.debug("Null - No file exist!"); } } else { LOG.warn("The widget does not exist."); } } else { LOG.info("Files were not deleted or folder was not found!"); } }
From source file:com.stratio.qa.specs.CommonG.java
License:Apache License
/** * Capture a snapshot or an evidence in the driver * * @param driver driver used for testing * @param type type/*from w ww .ja v a 2 s . c o m*/ * @param suffix suffix * @return String */ public String captureEvidence(WebDriver driver, String type, String suffix) { String testSuffix = System.getProperty("TESTSUFFIX"); String dir = "./target/executions/"; if (testSuffix != null) { dir = dir + testSuffix + "/"; } String clazz = ThreadProperty.get("class"); String currentBrowser = ThreadProperty.get("browser"); String currentData = ThreadProperty.get("dataSet"); if (!currentData.equals("")) { currentData = currentData.replaceAll("[\\\\|\\/|\\|\\s|:|\\*]", "_"); } if (!"".equals(currentData)) { currentData = "-" + HashUtils.doHash(currentData); } Timestamp ts = new Timestamp(new java.util.Date().getTime()); String outputFile = dir + clazz + "/" + ThreadProperty.get("feature") + "." + ThreadProperty.get("scenario") + "/" + currentBrowser + currentData + ts.toString() + suffix; outputFile = outputFile.replaceAll(" ", "_"); if (type.endsWith("htmlSource")) { if (type.equals("framehtmlSource")) { boolean isFrame = (Boolean) ((JavascriptExecutor) driver) .executeScript("return window.top != window.self"); if (isFrame) { outputFile = outputFile + "frame.html"; } else { outputFile = ""; } } else if (type.equals("htmlSource")) { driver.switchTo().defaultContent(); outputFile = outputFile + ".html"; } if (!outputFile.equals("")) { String source = ((RemoteWebDriver) driver).getPageSource(); File fout = new File(outputFile); boolean dirs = fout.getParentFile().mkdirs(); FileOutputStream fos; try { fos = new FileOutputStream(fout, true); Writer out = new OutputStreamWriter(fos, "UTF8"); PrintWriter writer = new PrintWriter(out, false); writer.append(source); writer.close(); out.close(); } catch (IOException e) { logger.error("Exception on evidence capture", e); } } } else if ("screenCapture".equals(type)) { outputFile = outputFile + ".png"; File file = null; driver.switchTo().defaultContent(); ((Locatable) driver.findElement(By.tagName("body"))).getCoordinates().inViewPort(); if (currentBrowser.startsWith("chrome") || currentBrowser.startsWith("droidemu")) { Actions actions = new Actions(driver); actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform(); actions.keyUp(Keys.CONTROL).perform(); file = chromeFullScreenCapture(driver); } else { file = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); } try { FileUtils.copyFile(file, new File(outputFile)); } catch (IOException e) { logger.error("Exception on copying browser screen capture", e); } } return outputFile; }
From source file:com.vaadin.testbench.TestBenchElement.java
@Override public void click(int x, int y, Keys... modifiers) { waitForVaadin();/* w ww . ja va2 s .co m*/ Actions actions = new Actions(getCommandExecutor().getWrappedDriver()); actions.moveToElement(actualElement, x, y); // Press any modifier keys for (Keys modifier : modifiers) { actions.keyDown(modifier); } actions.click(); // Release any modifier keys for (Keys modifier : modifiers) { actions.keyUp(modifier); } actions.build().perform(); }
From source file:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java
License:Open Source License
/** * This allow to select multiple web elements matching the given path. * * @param path: to list of elements/* w w w .j a v a 2 s . co m*/ * @param expectedElementCount: number of expected elements */ protected void selectMultipleElementsByPath(final By path, final int expectedElementCount) { List<WebElement> els = getElements(path, expectedElementCount); Actions multiSelect = new Actions(driver).keyDown(Keys.CONTROL); for (WebElement el : els) { multiSelect = multiSelect.click(el); } multiSelect.keyUp(Keys.CONTROL).build().perform(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** * Select text in defined interval//from w w w. j a v a 2 s. co m * * @param fromLine beginning of first line for selection * @param numberOfLine end of first line for selection */ public void selectLines(int fromLine, int numberOfLine) { Actions action = seleniumWebDriverHelper.getAction(seleniumWebDriver); setCursorToLine(fromLine); action.keyDown(SHIFT).perform(); for (int i = 0; i < numberOfLine; i++) { typeTextIntoEditor(Keys.ARROW_DOWN.toString()); } action.keyUp(SHIFT).perform(); action.sendKeys(Keys.END.toString()).keyUp(SHIFT).perform(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** Launches code assistant by "ctrl" + "space" keys pressing. */ public void launchAutocomplete() { Actions action = actionsFactory.createAction(seleniumWebDriver); action.keyDown(CONTROL).perform();// www .j av a 2 s .com typeTextIntoEditor(SPACE.toString()); action.keyUp(CONTROL).perform(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** Launches the "code assist proposition" container */ public void launchPropositionAssistPanel() { loader.waitOnClosed();/*w w w. j a v a2 s. c om*/ Actions action = actionsFactory.createAction(seleniumWebDriver); action.keyDown(ALT).perform(); action.sendKeys(ENTER).perform(); action.keyUp(ALT).perform(); waitPropositionAssistContainer(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** Launches the "code assist proposition" container in JS files */ public void launchPropositionAssistPanelForJSFiles() { loader.waitOnClosed();//ww w. j a va 2s . c om Actions action = actionsFactory.createAction(seleniumWebDriver); action.keyDown(LEFT_CONTROL).perform(); action.sendKeys(SPACE).perform(); action.keyUp(LEFT_CONTROL).perform(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** * Deletes line with specified {@code numberOfLine}. * * @param numberOfLine number of line which should be deleted *//*from w w w. j av a 2s . co m*/ public void selectLineAndDelete(int numberOfLine) { Actions action = actionsFactory.createAction(seleniumWebDriver); setCursorToLine(numberOfLine); typeTextIntoEditor(HOME.toString()); action.keyDown(SHIFT).perform(); typeTextIntoEditor(END.toString()); action.keyUp(SHIFT).perform(); typeTextIntoEditor(DELETE.toString()); loader.waitOnClosed(); }
From source file:org.eclipse.che.selenium.pageobject.CodenvyEditor.java
License:Open Source License
/** Deletes current editor's line. */ public void selectLineAndDelete() { Actions action = actionsFactory.createAction(seleniumWebDriver); typeTextIntoEditor(HOME.toString()); action.keyDown(SHIFT).perform();//from w ww . ja v a2 s . com typeTextIntoEditor(END.toString()); action.keyUp(SHIFT).perform(); typeTextIntoEditor(DELETE.toString()); }