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.gss_project.gss.web.client.selenium.tests.ActionUtils.java
License:Open Source License
public void sendRightClick(By locator) { WebElement element = driver.findElement(locator); element.sendKeys(Keys.chord(Keys.SHIFT, Keys.F10)); }
From source file:org.gss_project.gss.web.client.selenium.tests.FolderUtils.java
License:Open Source License
public void testRightClickOnFolder1() throws InterruptedException { action.click(By.id(userName + "." + folderName)); System.out.println("userName = " + userName); System.out.println("folderName = " + folderName); Thread.sleep(1000);/* ww w. j ava 2s .c o m*/ WebElement element = driver.findElement(By.id(userName + "." + folderName)); element.sendKeys(Keys.chord(Keys.SHIFT, Keys.F10)); Thread.sleep(2000); // action.sendRightClick(By.id(userName+ "." + folderName)); action.click(By.id("folderContextMenu.newFolder")); Thread.sleep(1000); }
From source file:org.gss_project.gss.web.client.selenium.tests.TestFileBasics.java
License:Open Source License
public void testRightClickOnFile() throws InterruptedException { /**/* w w w . j a va2s .c o m*/ * Q: The "onchange" event doesn't fire after a call "sendKeys" * A: WebDriver leaves the focus in the element you called "sendKeys" on. * The "onchange" event will only fire when focus leaves that element. * As such, you need to move the focus, perhaps using a "click" on another element. * * http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions */ action.click(By.id("lakis@ebs.gr.Alderaan")); action.click(By.id("fileList.natasa.gif")); WebElement element = driver.findElement(By.id("fileList.natasa.gif")); element.sendKeys(Keys.chord(Keys.SHIFT, Keys.F10)); Thread.sleep(2000); action.click(By.id("fileContextMenu.properties")); }
From source file:org.mousephenotype.cda.selenium.support.TestUtils.java
License:Apache License
/** * There is a selenium bug that silently removes opening parentheses from * a sendkeys string. See http://stackoverflow.com/questions/19704559/selenium-sendkeys-not-working-for-open-brackets-and-harsh-keys-when-using-java * * This is the workaround./*from ww w.ja v a2 s . c o m*/ * * @param element <code>WebElement</code> against which to use the sendKeys * @param text the text to send (may contain open parenthesis) */ public void seleniumSendKeysHack(WebElement element, String text) { char[] chars = text.toCharArray(); for (char c : chars) { if (c == '(') { element.sendKeys(Keys.chord(Keys.SHIFT, "9")); } else { StringBuffer sb = new StringBuffer().append(c); element.sendKeys(sb); } } }
From source file:org.mousephenotype.www.testing.model.TestUtils.java
License:Apache License
/** * There is a selenium bug that silently removes opening parentheses from * a sendkeys string. See http://stackoverflow.com/questions/19704559/selenium-sendkeys-not-working-for-open-brackets-and-harsh-keys-when-using-java * /* w ww . jav a 2 s .com*/ * This is the workaround. * * @param element <code>WebElement</code> against which to use the sendKeys * @param text the text to send (may contain open parenthesis) */ public static void seleniumSendKeysHack(WebElement element, String text) { char[] chars = text.toCharArray(); for (char c : chars) { if (c == '(') { element.sendKeys(Keys.chord(Keys.SHIFT, "9")); } else { StringBuffer sb = new StringBuffer().append(c); element.sendKeys(sb); } } }
From source file:org.natica.expense.ExpenseImport.java
public void importExpenes(List<Expense> expenses, String username, String password) { setUpDriverConfig(ExpenseConstants.WAITSECONDS); openBrowser();// w ww . j a v a 2s. c o m login(username, password); goToExpensePage(); for (Expense e : expenses) { WebElement calendarButton = driver.findElement(By.xpath(ExpenseConstants.CALENDARPOPUPXPATH)); calendarButton.click(); String activeMonthYear = driver.findElement(By.xpath(ExpenseConstants.CALENDARACTIVEMONTHXPATH)) .getText(); DateFormat format = new SimpleDateFormat("MMMM yyyy"); Date activeDate = null; try { activeDate = format.parse(activeMonthYear); } catch (ParseException ex) { Logger.getLogger(ExpenseImport.class.getName()).log(Level.SEVERE, null, ex); } Calendar activeDateCal = Calendar.getInstance(); activeDateCal.setTime(activeDate); Calendar expenseEntryDateCal = Calendar.getInstance(); expenseEntryDateCal.setTime(e.getExpenseEntryDate()); goToExpenseMonth(activeDateCal, expenseEntryDateCal); WebElement expenseDay = findDay(expenseEntryDateCal.get(Calendar.DAY_OF_MONTH), expenseEntryDateCal.getActualMaximum(Calendar.DATE)); expenseDay.click(); WebElement showButton = driver.findElement(By.xpath(ExpenseConstants.SHOWBUTTONXPATH)); showButton.click(); WebElement projectName = driver.findElement(By.xpath(ExpenseConstants.PROJECTNAMEXPATH)); Select projectNameSelect = new Select(projectName); projectNameSelect.selectByVisibleText(e.getProjectName()); WebElement expenseName = driver.findElement(By.xpath(ExpenseConstants.EXPENSENAMEXPATH)); Select expenseNameSelect = new Select(expenseName); expenseNameSelect.selectByVisibleText(e.getExpenseName()); expenseName.sendKeys(Keys.TAB); waitSeconds(3); WebElement description = driver.findElement(By.xpath(ExpenseConstants.EXPENSEDESCRIPTIONXPATH)); description.sendKeys(Keys.chord(Keys.CONTROL, "a"), e.getDescription()); description.sendKeys(Keys.TAB); WebElement paymentMethod = driver.findElement(By.xpath(ExpenseConstants.PAYMENTMETHODXPATH)); Select paymentMethodSelect = new Select(paymentMethod); paymentMethodSelect.selectByVisibleText(e.getPaymentMethod()); WebElement netAmount = driver.findElement(By.xpath(ExpenseConstants.NETAMOUNTXPATH)); netAmount.sendKeys(Keys.HOME, Keys.chord(Keys.SHIFT, Keys.END), e.getNetAmount().toString().replace(".", ",")); netAmount.sendKeys(Keys.TAB); waitSeconds(3); WebElement addButton = driver.findElement(By.xpath(ExpenseConstants.ADDBUTTONXPATH)); addButton.click(); acceptNextAlert = true; closeAlertAndGetItsText(); WebElement submitButton = driver.findElement(By.xpath(ExpenseConstants.SUBMITBUTTONXPATH)); submitButton.click(); } }
From source file:org.nvonop.selenium.framework.controls.TextBox.java
License:Open Source License
@Override public void write(String value) { getUnderlyingWebElement().sendKeys(Keys.HOME); getUnderlyingWebElement().sendKeys(Keys.SHIFT, Keys.END, Keys.DELETE); getUnderlyingWebElement().sendKeys(value); }
From source file:org.richfaces.tests.metamer.ftest.richCalendar.TestCalendarModel.java
License:Open Source License
@Test @IssueTracking("https://issues.jboss.org/browse/RF-14199") public void testDisabledDayCannotBePickedByKeyboard() { DateTime referenceDate = new DateTime().withYear(2015).withMonthOfYear(11).withDayOfMonth(2) .withHourOfDay(12).withMinuteOfHour(0); // set reference date Graphene.guardAjax(popupCalendar).setDateTime(referenceDate); performStabilizationWorkaround();//from ww w . j a v a 2s.com popupCalendar.openPopup(); checkSelectedDate(referenceDate); // try to select tuesday (disabled) keyboard.sendKeys(Keys.ARROW_RIGHT); keyboard.sendKeys(Keys.ENTER); assertTrue(popupCalendar.getPopup().isVisible()); // check date is still the same (no move through enabled and already not selected days) checkSelectedDate(referenceDate); // try to select sunday (disabled) keyboard.sendKeys(Keys.ARROW_LEFT); keyboard.sendKeys(Keys.ARROW_LEFT); keyboard.sendKeys(Keys.ENTER); assertTrue(popupCalendar.getPopup().isVisible()); // check date is still the same (no move through enabled and already not selected days) checkSelectedDate(referenceDate); // try to select saturday from previous month (disabled) Graphene.guardAjax(keyboard).sendKeys(Keys.ARROW_LEFT);// move to previous month will trigger an ajax request keyboard.sendKeys(Keys.ENTER); assertTrue(popupCalendar.getPopup().isVisible()); // check date is still the same (no move through enabled and already not selected days) checkSelectedDate(referenceDate); // try to select thursday from previous year (disabled) Graphene.guardAjax(keyboard).sendKeys(Keys.chord(Keys.SHIFT, Keys.PAGE_UP));// move to previous year will trigger an ajax request keyboard.sendKeys(Keys.ARROW_LEFT); keyboard.sendKeys(Keys.ENTER); assertTrue(popupCalendar.getPopup().isVisible()); // check selected date has changed (day moved to friday when the year was switched) // 2x to the left and 1x to previous year referenceDate = referenceDate.minusDays(2).minusYears(1); checkSelectedDate(referenceDate); // finally, select wednesday (enabled) Graphene.guardAjax(keyboard).sendKeys(Keys.ARROW_LEFT); keyboard.sendKeys(Keys.ENTER); popupCalendar.getPopup().waitUntilIsNotVisible().perform(); referenceDate = referenceDate.withYear(2014).withMonthOfYear(10).withDayOfMonth(29); checkSelectedDate(referenceDate); }
From source file:org.richfaces.tests.metamer.ftest.richExtendedDataTable.TestExtendedDataTableSelection.java
License:Open Source License
@Test @CoversAttributes({ "selection", "selectionMode" }) public void testSelectionModeMultipleKeyboardFree() { tableAttributes.set(ExtendedDataTableAttributes.selectionMode, "multipleKeyboardFree"); page.selectRow(2);/*from w w w . j a va2 s . c o m*/ assertEquals(page.getActualPreviousSelection(), expectedSelection()); assertEquals(page.getActualCurrentSelection(), expectedSelection(2)); // select another row page.selectRow(4); assertEquals(page.getActualPreviousSelection(), expectedSelection(2)); assertEquals(page.getActualCurrentSelection(), expectedSelection(2, 4)); // select another record using CONTROL (no effect), another record is selected page.selectRow(7, Keys.CONTROL); assertEquals(page.getActualPreviousSelection(), expectedSelection(2, 4)); assertEquals(page.getActualCurrentSelection(), expectedSelection(2, 4, 7)); // select another record using SHIFT (no effect), another record is selected page.selectRow(0, Keys.SHIFT); assertEquals(page.getActualPreviousSelection(), expectedSelection(2, 4, 7)); assertEquals(page.getActualCurrentSelection(), expectedSelection(0, 2, 4, 7)); // deselect previously selected row page.deselectRow(4);// selecting and deselecting is performed by the same mechanism -- clicking on the row assertEquals(page.getActualPreviousSelection(), expectedSelection(0, 2, 4, 7)); assertEquals(page.getActualCurrentSelection(), expectedSelection(0, 2, 7)); }
From source file:org.richfaces.tests.metamer.ftest.richExtendedDataTable.TestExtendedDataTableSelection.java
License:Open Source License
@Test @IssueTracking("https://issues.jboss.org/browse/RF-11932") @CoversAttributes({ "selection", "selectionMode" }) public void testSelectionModeSingle() { tableAttributes.set(ExtendedDataTableAttributes.selectionMode, "single"); page.selectRow(2);// ww w . jav a 2 s.com assertEquals(page.getActualPreviousSelection(), expectedSelection()); assertEquals(page.getActualCurrentSelection(), expectedSelection(2)); // select another record using CONTROL, only one record is selected page.selectRow(4, Keys.CONTROL); assertEquals(page.getActualPreviousSelection(), expectedSelection(2)); assertEquals(page.getActualCurrentSelection(), expectedSelection(4)); // select another record using SHIFT, only one record is selected page.selectRow(7, Keys.SHIFT); assertEquals(page.getActualPreviousSelection(), expectedSelection(4)); assertEquals(page.getActualCurrentSelection(), expectedSelection(7)); // select another record using CONTROL+SHIFT, only one record is selected page.selectRow(3, Keys.CONTROL, Keys.SHIFT); assertEquals(page.getActualPreviousSelection(), expectedSelection(7)); assertEquals(page.getActualCurrentSelection(), expectedSelection(3)); // deselect row page.deselectRow(3, Keys.CONTROL); assertEquals(page.getActualPreviousSelection(), expectedSelection(3)); assertEquals(page.getActualCurrentSelection(), expectedSelection()); }