List of usage examples for org.openqa.selenium Keys HOME
Keys HOME
To view the source code for org.openqa.selenium Keys HOME.
Click Source Link
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 . j av a2 s. c om * @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.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;//from w w w . ja va2s. c om }
From source file:com.vaadin.tests.components.grid.basicfeatures.server.GridKeyboardNavigationTest.java
License:Apache License
@Test public void testHomeEnd() throws Exception { openTestURL();/*from ww w.j a v a 2s .c om*/ getGridElement().getCell(100, 2).click(); new Actions(getDriver()).sendKeys(Keys.HOME).perform(); assertTrue("First row is not visible", getGridElement().getCell(0, 2).isDisplayed()); new Actions(getDriver()).sendKeys(Keys.END).perform(); assertTrue("Last row cell not visible", getGridElement().getCell(GridBasicFeatures.ROWS - 1, 2).isDisplayed()); }
From source file:org.auraframework.components.ui.inputDate.BaseInputDateUITester.java
License:Apache License
/*********************************************************************************************** *********************************** Date Picker Tests******************************************* ***********************************************************************************************/ // Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days) @ExcludeBrowsers({ BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE })/*from ww w . j a v a2 s .c o m*/ public void testHomeEnd() throws Exception { open(URL); // Checking January (31 days) String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME); assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END); assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult); // Checking February (28 or 29 days), none Leap year inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2011-02-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult); // Checking February (28 or 29 days), Leap year inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2012-02-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult); // Checking September (30 days) inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME); assertEquals("The Home button did not go to the beginning of September", "2011-09-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END); assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult); }
From source file:org.auraframework.components.ui.inputDate.InputDateWithLabelUITest.java
License:Apache License
/*********************************************************************************************** *********************************** Date Picker Tests******************************************* ***********************************************************************************************/ // Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days) @ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE8, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE }) public void testHomeEnd() throws Exception { open(URL);//from ww w . j av a 2s .c o m // Checking January (31 days) String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME); assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END); assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult); // Checking February (28 or 29 days), none Leap year inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2011-02-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult); // Checking February (28 or 29 days), Leap year inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2012-02-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult); // Checking September (30 days) inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME); assertEquals("The Home button did not go to the beginning of September", "2011-09-01", inputBoxResult); inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END); assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult); }
From source file:org.auraframework.integration.test.components.ui.inputDate.InputDateWithLabelUITest.java
License:Apache License
/*********************************************************************************************** *********************************** Date Picker Tests******************************************* ***********************************************************************************************/ // Home and End Button Test using January (31 days) , February (28 or 29 days), September (30 days) @ExcludeBrowsers({ BrowserType.IE7, BrowserType.IE8, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE }) @Test/* w w w .j a v a 2 s . c o m*/ public void testHomeEnd() throws Exception { open(URL); // Checking January (31 days) String inputBoxResult = homeEndButtonHelper("2011-1-31", Keys.HOME); assertEquals("The Home button did not go to the beginning of January", "2011-01-01", inputBoxResult.trim()); inputBoxResult = homeEndButtonHelper("2011-1-1", Keys.END); assertEquals("The End button did not go to the end of January", "2011-01-31", inputBoxResult.trim()); // Checking February (28 or 29 days), none Leap year inputBoxResult = homeEndButtonHelper("2011-2-28", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2011-02-01", inputBoxResult.trim()); inputBoxResult = homeEndButtonHelper("2011-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2011-02-28", inputBoxResult.trim()); // Checking February (28 or 29 days), Leap year inputBoxResult = homeEndButtonHelper("2012-2-29", Keys.HOME); assertEquals("The Home button did not go to the beginning of February", "2012-02-01", inputBoxResult.trim()); inputBoxResult = homeEndButtonHelper("2012-2-1", Keys.END); assertEquals("The End button did not go to the end of February", "2012-02-29", inputBoxResult.trim()); // Checking September (30 days) inputBoxResult = homeEndButtonHelper("2011-9-30", Keys.HOME); assertEquals("The Home button did not go to the beginning of September", "2011-09-01", inputBoxResult.trim()); inputBoxResult = homeEndButtonHelper("2011-9-1", Keys.END); assertEquals("The End button did not go to thes end of September", "2011-09-30", inputBoxResult.trim()); }
From source file:org.auraframework.integration.test.localization.LocalizationAppUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE }) // Checking functionality of the inputPercent/outputPercent components @Test/*from w w w. j a v a2 s .c om*/ public void testPercentComponents() throws Exception { open(URL); // initial load By outputSelector = By.cssSelector("span[class~='uiOutputPercent']"); WebElement elementInput = findDomElement(By.cssSelector("input[class~='uiInputPercent']")); WebElement elementoutput = findDomElement(outputSelector); assertEquals("InputPercent component rendered with wrong value", "1,235%", elementInput.getAttribute("value")); assertEquals("outputPercent component rendered with wrong value", "1,235%", elementoutput.getText()); // Tab out elementInput.click(); elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END)); elementInput.sendKeys("22.35"); getAuraUITestingUtil().pressTab(elementInput); getAuraUITestingUtil().waitForElementText(outputSelector, "22%", true, "outputPercent component rendered with wrong value"); assertEquals("InputPercent component rendered with wrong value", "22%", elementInput.getAttribute("value")); // Submit click elementInput.click(); elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END)); elementInput.sendKeys("1.2235"); WebElement elementButton = findDomElement(By.cssSelector("button[title~='Percent']")); elementButton.click(); getAuraUITestingUtil().waitForElementText(outputSelector, "1%", true, "outputPercent component rendered with wrong value"); assertEquals("InputPercent component rendered with wrong value", "1%", elementInput.getAttribute("value")); }
From source file:org.auraframework.integration.test.localization.LocalizationAppUITest.java
License:Apache License
@ExcludeBrowsers({ BrowserType.IE9, BrowserType.IE10, BrowserType.SAFARI, BrowserType.ANDROID_PHONE, BrowserType.ANDROID_TABLET, BrowserType.IPAD, BrowserType.IPHONE }) // Checking functionality of the inputCurrency/outputCurrency components @Test/*from w w w . ja v a 2 s . co m*/ public void testCurrencyComponents() throws Exception { open(URL); // initial load By outputSelector = By.cssSelector("span[class~='uiOutputCurrency']"); WebElement elementInput = findDomElement(By.cssSelector("span[id='MyCurrency'] > input[class~='uiInput']")); WebElement elementOutput = findDomElement(outputSelector); assertEquals("InputCurrency component rendered with wrong value", "$123,456.79", elementInput.getAttribute("value")); assertEquals("outputCurrency component rendered with wrong value", "$123,456.79", elementOutput.getText()); // Tab out elementInput.click(); elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END)); elementInput.sendKeys("123456"); getAuraUITestingUtil().pressTab(elementInput); getAuraUITestingUtil().waitForElementText(outputSelector, "$123,456.00", true, "OutputCurrency component rendered with wrong value"); assertEquals("InputCurrency component rendered with wrong value", "$123,456.00", elementInput.getAttribute("value")); // Submit click elementInput.click(); elementInput.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END)); elementInput.sendKeys("123.45"); WebElement elementButton = findDomElement(By.cssSelector("button[title~='Currency']")); elementButton.click(); getAuraUITestingUtil().waitForElementText(outputSelector, "$123.45", true, "OutputCurrency component rendered with wrong value"); assertEquals("InputCurrency component rendered with wrong value", "$123.45", elementInput.getAttribute("value")); }
From source file:org.eclipse.che.selenium.core.action.GenericActionsTest.java
License:Open Source License
@Test public void testShouldReturnSameCharSequence() throws Exception { GenericActions actions = new GenericActions(webDriver); final CharSequence[] charSequences = actions.modifyCharSequence(Keys.END, Keys.HOME, Keys.PAGE_DOWN, Keys.PAGE_UP);/*from w w w . j a v a 2 s .c o m*/ assertNotNull(charSequences); assertEquals(charSequences.length, 4); assertEquals(charSequences[0], Keys.END); assertEquals(charSequences[1], Keys.HOME); assertEquals(charSequences[2], Keys.PAGE_DOWN); assertEquals(charSequences[3], Keys.PAGE_UP); }
From source file:org.eclipse.che.selenium.core.action.MacOSActions.java
License:Open Source License
@Override protected CharSequence[] modifyCharSequence(CharSequence... keysToSend) { final List<CharSequence> modKeysToSend = newArrayList(); for (CharSequence charSequence : keysToSend) { final String key = charSequence.toString(); if (Keys.END.toString().equals(key)) { modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.RIGHT)); } else if (Keys.HOME.toString().equals(key)) { modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.LEFT)); } else if (Keys.PAGE_UP.toString().equals(key)) { modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.UP)); } else if (Keys.PAGE_DOWN.toString().equals(key)) { modKeysToSend.add(Keys.chord(Keys.COMMAND, Keys.DOWN)); } else {/*from w w w .ja va2 s . c o m*/ modKeysToSend.add(charSequence); } } return modKeysToSend.toArray(new CharSequence[modKeysToSend.size()]); }