List of usage examples for org.openqa.selenium Keys CONTROL
Keys CONTROL
To view the source code for org.openqa.selenium Keys CONTROL.
Click Source Link
From source file:org.nuxeo.functionaltests.ITSafeEditTest.java
License:Open Source License
/** * This methods checks that once a simple html input is changed within a * page, the new value is stored in the browser local storage in case of * accidental loose (crash, freeze, network failure). The value can then be * restored from the local storage when re-editing the page afterwards. * * @since 5.7.1/* www . ja v a 2 s .c o m*/ */ @Test public void testAutoSaveOnChangeAndRestore() throws Exception { if (!runTestForBrowser()) { log.warn("Browser not supported. Nothing to run."); return; } prepare(); DocumentBasePage documentBasePage; WebElement descriptionElt, titleElt; // Log as test user and edit the created workdspace documentBasePage = login(USERNAME, PASSWORD).getContentTab().goToDocument("Workspaces").getContentTab() .goToDocument(WORKSPACE_TITLE); documentBasePage.getEditTab(); LocalStorage localStorage = new LocalStorage(driver); localStorage.clearLocalStorage(); String currentDocumentId = getCurrentDocumentId(); descriptionElt = driver.findElement(By.name(DESCRIPTION_ELT_ID)); titleElt = driver.findElement(By.name(TITLE_ELT_ID)); log.debug("1 - " + localStorage.getLocalStorageLength()); // We change the value of the title Keys ctrlKey = Keys.CONTROL; if (Platform.MAC.equals(driver.getCapabilities().getPlatform())) { ctrlKey = Keys.COMMAND; } titleElt.click(); titleElt.sendKeys(Keys.chord(ctrlKey, "a") + Keys.DELETE + NEW_WORKSPACE_TITLE); // weird thing in webdriver: we need to call clear on an input of the // form to fire an onchange event descriptionElt.click(); descriptionElt.clear(); log.debug("2 - " + localStorage.getLocalStorageLength()); // Now must have something saved in the localstorage String lsItem = localStorage.getItemFromLocalStorage(currentDocumentId); final String lookupString = "\"" + TITLE_ELT_ID + "\":\"" + NEW_WORKSPACE_TITLE + "\""; assertTrue(lsItem != null && lsItem.length() > 0); assertTrue(lsItem.contains(lookupString)); // Let's leave the edit tab of the workspace with unsaved changes. A // popup should prevent us from doing that try { documentBasePage.getContentTab(); // Should never occur fail("There are unsaved modifications pending and the page can only be left after clicking \"Leave this page\""); } catch (UnhandledAlertException e) { // Expected behavior // The following is a workaround to by pass the popup windows which // is supposed to prevent the user from leaving the page with // unsaved modifications log.debug("3 - " + localStorage.getLocalStorageLength()); byPassLeavePagePopup(); log.debug("4 - " + localStorage.getLocalStorageLength()); } // We leave the page and get back to it. Since we didn't save, the // title must be the initial one. documentBasePage.getContentTab(); documentBasePage.getEditTab(); localStorage = new LocalStorage(driver); titleElt = findElementWithTimeout(By.name(TITLE_ELT_ID)); String titleEltValue = titleElt.getAttribute("value"); assertTrue(titleEltValue.equals(WORKSPACE_TITLE)); log.debug("5 - " + localStorage.getLocalStorageLength()); // We must find in the localstorage an entry matching the previous // document which contains the title we edited lsItem = localStorage.getItemFromLocalStorage(currentDocumentId); assertTrue(lsItem.contains(lookupString)); log.debug("6 - " + localStorage.getLocalStorageLength()); checkSafeEditRestoreProvided(); triggerSafeEditResotre(); // We check that the title value has actually been restored titleElt = driver.findElement(By.name(TITLE_ELT_ID)); titleEltValue = titleElt.getAttribute("value"); assertTrue(titleEltValue.equals(NEW_WORKSPACE_TITLE)); byPassLeavePagePopup(); documentBasePage.getContentTab(); logout(); restoreSate(); }
From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java
License:Open Source License
public static void windowZoomOut() { final int zoomOutFactor = 2; for (int i = 0; i < zoomOutFactor; i++) { driver.findElement(By.tagName("html")).sendKeys(Keys.chord(Keys.CONTROL, Keys.SUBTRACT)); }/*from w ww . ja v a 2 s. c o m*/ }
From source file:org.richfaces.bootstrap.demo.ftest.webdriver.pickList.fragment.PickListSelectionImpl.java
License:Open Source License
private void select() { if (selection.size() > 1) { //multiple selection is not working Actions builder = new Actions(driver); boolean firstrun = true; for (WebElement keyElement : selection) { builder.click(keyElement);//also deselect previous selected elements if (firstrun) { firstrun = false;/*from w w w . j ava2s . c om*/ builder.keyDown(Keys.CONTROL); } } builder.keyUp(Keys.CONTROL); builder.build().perform(); } else { selection.get(0).click(); } }
From source file:org.richfaces.fragment.inplaceInput.AbstractConfirmOrCancel.java
License:Open Source License
@Override public void confirm() { new Actions(getBrowser()).sendKeys(Keys.chord(Keys.CONTROL, Keys.RETURN)).perform(); waitAfterConfirmOrCancel(); }
From source file:org.richfaces.fragment.inplaceInput.AbstractConfirmOrCancel.java
License:Open Source License
@Override public void cancel() { getInput().sendKeys(Keys.chord(Keys.CONTROL, Keys.ESCAPE)); waitAfterConfirmOrCancel(); }
From source file:org.richfaces.fragment.orderingList.AbstractOrderingList.java
License:Open Source License
protected void selectItem(final WebElement item) { new Actions(driver).keyDown(Keys.CONTROL).click(item).keyUp(Keys.CONTROL).addAction(new Action() { @Override/* w w w. j av a 2s. c o m*/ public void perform() { Graphene.waitGui().until().element(item).attribute("class") .contains(getBody().getStyleForSelectedItem()); } }).perform(); }
From source file:org.richfaces.fragment.orderingList.AbstractOrderingList.java
License:Open Source License
protected void unselectAll() { if (!getBody().getSelectedItems().isEmpty()) { new Actions(driver).click(getBody().getItemsElements().get(0)).keyDown(Keys.CONTROL) .click(getBody().getItemsElements().get(0)).keyUp(Keys.CONTROL).addAction(new Action() { @Override// w w w. j a v a 2 s . c o m public void perform() { Graphene.waitGui().until().element(getBody().getItemsElements().get(0)) .attribute("class").not().contains("rf-ord-sel"); } }).perform(); if (!getBody().getSelectedItems().isEmpty()) { throw new RuntimeException("The unselection was not successfull."); } } }
From source file:org.richfaces.fragment.orderingList.AbstractSelectableListItem.java
License:Open Source License
@Override public void select(boolean deselectOthers) { if (deselectOthers) { new Actions(driver).click(getRootElement()).addAction(new Action() { @Override/*from ww w. j a va2 s. c o m*/ public void perform() { Graphene.waitGui().until().element(getRootElement()).attribute("class") .contains(getStyleClassForSelectedItem()); } }).perform(); } else { if (!isSelected()) { new Actions(driver).keyDown(Keys.CONTROL).click(getRootElement()).keyUp(Keys.CONTROL) .addAction(new Action() { @Override public void perform() { Graphene.waitGui().until().element(getRootElement()).attribute("class") .contains(getStyleClassForSelectedItem()); } }).perform(); } } }
From source file:org.richfaces.fragment.orderingList.AbstractSelectableListItem.java
License:Open Source License
@Override public void deselect() { if (isSelected()) { new Actions(driver).keyDown(Keys.CONTROL).click(getRootElement()).keyUp(Keys.CONTROL) .addAction(new Action() { @Override//from w w w. j a v a2s. com public void perform() { Graphene.waitGui().until().element(getRootElement()).attribute("class").not() .contains(getStyleClassForSelectedItem()); } }).perform(); } }
From source file:org.richfaces.fragment.pickList.RichFacesPickList.java
License:Open Source License
private void selectItem(final WebElement item) { new Actions(driver).keyDown(Keys.CONTROL).click(item).keyUp(Keys.CONTROL).addAction(new Action() { @Override//from w w w . j a v a2s. c om public void perform() { Graphene.waitGui().until().element(item).attribute("class") .contains(OrderingListInPickList.SELECTED_ITEM_CLASS); } }).perform(); }