List of usage examples for org.openqa.selenium Keys ESCAPE
Keys ESCAPE
To view the source code for org.openqa.selenium Keys ESCAPE.
Click Source Link
From source file:org.specrunner.webdriver.actions.input.keyboard.PluginEsc.java
License:Open Source License
@Override protected Keys obtainKey() throws PluginException { return Keys.ESCAPE; }
From source file:org.testeditor.fixture.web.angularjs.materialdesign.NgMdWebDriverFixture.java
License:Open Source License
/** * @return the Options of a selection Field as a {@code JsonObject} * @param elementLocator Locator for Selection *//* ww w . jav a 2 s. c om*/ @FixtureMethod public JsonObject getOptionsInSelection(String elementLocator, LocatorStrategy locatorStrategy) throws FixtureException { JsonObject availableOptions = new JsonObject(); clickOn(elementLocator, locatorStrategy); wrappedSleep(300, "get option in selection interrupted", FixtureException.keyValues("elementLocator", elementLocator, "locatorStrategy", locatorStrategy.toString())); waitForAngularCompleteOperations(); ByAngularCssContainingText cssContainingText = ByAngular.cssContainingText("md-option", ""); List<WebElement> options = getDriver().findElements(cssContainingText); for (WebElement element : options) { if (element.isDisplayed()) { availableOptions.addProperty(element.getText(), element.getText()); } } Actions actions = new Actions(getDriver()); actions.sendKeys(Keys.ESCAPE).perform(); return availableOptions; }
From source file:org.xwiki.annotation.test.po.AnnotationsLabel.java
License:Open Source License
public String getAnnotationContentByText(String searchText) { hoverOnAnnotationByText(searchText); waitUntilElementIsVisible(By.xpath("//div[@class='annotationText']/p")); String annotationContent = getDriver() .findElement(By.xpath("//*[@class='annotation-bubble']//div[@class='annotationText']/p")).getText(); WebElement body = getDriver().findElement(By.id("body")); // It seems that hovering over the small yellow icon sends 2 requests, and one ESC is not enough to make the // window disappear body.sendKeys(Keys.ESCAPE); body.sendKeys(Keys.ESCAPE);//from ww w . j ava 2 s . c om waitUntilElementDisappears(By.className("annotation-box-view")); return annotationContent; }
From source file:org.xwiki.appwithinminutes.test.po.ApplicationTemplateProviderEditPage.java
License:Open Source License
public ApplicationTemplateProviderEditPage setIcon(String icon) { this.iconInput.clear(); this.iconInput.sendKeys(icon); // Make sure the icon picker doesn't remain open. this.iconInput.sendKeys(Keys.ESCAPE); return this; }
From source file:org.xwiki.test.ui.annotations.elements.AnnotationsLabel.java
License:Open Source License
public String getAnnotationContentByText(String searchText) { showAnnotationByText(searchText);// w ww. j a v a 2s. com waitUntilElementIsVisible(By.xpath("//div[@class='annotationText']/p")); String annotationContent = getDriver() .findElement(By.xpath("//*[@class='annotation-bubble']//div[@class='annotationText']/p")).getText(); RenderedWebElement body = (RenderedWebElement) getDriver().findElement(By.id("body")); body.sendKeys(Keys.ESCAPE); waitUntilElementDisappears(By.className("annotation-box-view")); return annotationContent; }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testSuggestions() { UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker(); // The suggestions should be case-insensitive. Match the last name. List<UserElement> suggestions = userPicker.sendKeys("mOr").waitForSuggestions().getSuggestions(); Assert.assertEquals(2, suggestions.size()); assertUserElement(suggestions.get(0), "Eduard Moraru", "Enygma2002"); assertUserElement(suggestions.get(1), "Thomas Mortagne"); // Match the first name. suggestions = userPicker.sendKeys(Keys.BACK_SPACE, Keys.BACK_SPACE, "As").waitForSuggestions() .getSuggestions();/*from w ww. j a v a2 s . co m*/ Assert.assertEquals(1, suggestions.size()); assertUserElement(suggestions.get(0), "Thomas Mortagne"); // Match the alias. suggestions = userPicker.sendKeys(Keys.BACK_SPACE, "20").waitForSuggestions().getSuggestions(); Assert.assertEquals(1, suggestions.size()); assertUserElement(suggestions.get(0), "Eduard Moraru", "Enygma2002"); // The guest user shouldn't be suggested. suggestions = userPicker.clear().sendKeys("guest").waitForSuggestions().getSuggestions(); Assert.assertEquals(1, suggestions.size()); Assert.assertEquals("User not found", suggestions.get(0).getText()); // Default administrator user should be suggested. suggestions = userPicker.clear().sendKeys("admin").waitForSuggestions().getSuggestions(); Assert.assertEquals(1, suggestions.size()); assertUserElement(suggestions.get(0), "Administrator", "Admin", "noavatar.png"); // "a" should bring many suggestions. Also, a single letter should bring suggestions. Assert.assertTrue(userPicker.clear().sendKeys("a").waitForSuggestions().getSuggestions().size() > 2); // An empty text input shouldn't bring any suggestions. try { userPicker.sendKeys(Keys.BACK_SPACE).waitForSuggestions(); Assert.fail(); } catch (Exception e) { } // We should be able to close the list of suggestions using the escape key. userPicker.sendKeys("mor").waitForSuggestions().sendKeys(Keys.ESCAPE).waitForSuggestionsToFadeOut(); // The list of suggestions should close itself after a while. userPicker.moveMouseOver().sendKeys(Keys.BACK_SPACE).waitForSuggestions().waitForSuggestionsToDisappear(); // The list of suggestions should stay open if the mouse is over it. userPicker.sendKeys(Keys.BACK_SPACE).waitForSuggestions().getSuggestions().get(0).moveMouseOver(); try { userPicker.waitForSuggestionsToDisappear(); Assert.fail(); } catch (Exception e) { } // .. and the list of suggestions should fade out when the mouse is moved out. userPicker.moveMouseOver().waitForSuggestionsToFadeOut(); }
From source file:org.xwiki.test.ui.appwithinminutes.UserClassFieldTest.java
License:Open Source License
@Test public void testSaveAndInitialSelection() { UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker(); userPicker.sendKeys("thomas").waitForSuggestions().sendKeys(Keys.ENTER); editor.clickSaveAndView().edit();/* ww w .j a v a 2s .c o m*/ UserClassFieldEditPane userField = new UserClassFieldEditPane("user1"); userPicker = userField.getUserPicker().waitToLoad(); List<UserElement> selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(1, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); Assert.assertEquals("", userPicker.getValue()); // Enable multiple selection. userField.openConfigPanel(); userField.setMultipleSelect(true); userField.closeConfigPanel(); // Re-take the user picker because the display has been reloaded. userPicker = userField.getUserPicker(); // Select one more user. userPicker.waitToLoad().sendKeys("admin").waitForSuggestions().sendKeys(Keys.ENTER); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(2, selectedUsers.size()); assertUserElement(selectedUsers.get(0), "Thomas Mortagne"); assertUserElement(selectedUsers.get(1), "Administrator", "Admin", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); // We should be able to input free text also. userPicker.sendKeys("foobar").waitForSuggestions().sendKeys(Keys.ESCAPE).waitForSuggestionsToFadeOut(); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); selectedUsers = userPicker.getAcceptedSuggestions(); Assert.assertEquals(3, selectedUsers.size()); assertUserElement(selectedUsers.get(2), "foobar", "foobar", "noavatar.png"); Assert.assertEquals("", userPicker.getValue()); // Delete the fake user. selectedUsers.get(2).delete(); Assert.assertEquals(2, userPicker.getAcceptedSuggestions().size()); // Delete all selected users. userPicker.getClearSelectionLink().click(); editor.clickSaveAndContinue(); editor.clickCancel().edit(); userPicker = new UserClassFieldEditPane("user1").getUserPicker().waitToLoad(); Assert.assertEquals(0, userPicker.getAcceptedSuggestions().size()); Assert.assertEquals("", userPicker.getValue()); }
From source file:org.xwiki.test.ui.po.Select.java
License:Open Source License
/** * Sometimes the select drop down list remains opened after we select an option. This is a utility method to close * the drop down list.//w w w . ja v a 2 s . co m */ private void maybeCloseDropDownList() { if (!isMultiple()) { element.sendKeys(Keys.ESCAPE); } }
From source file:org.xwiki.test.wysiwyg.StandardFeaturesTest.java
License:Open Source License
/** * @see XWIKI-4665: Pressing Meta+G (Jump to page) in the WYSIWYG editor displays the popup inside the rich text * area./* w ww .j a v a 2 s .c om*/ */ @Test public void testJavaScriptExtensionsAreNotIncludedInEditMode() { // Type some text to be sure the conversion is triggered when switching to source. typeText("x"); // Type Ctrl+G to open the "Jump to page" dialog. getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g")); // Switch to source and check the result. switchToSource(); assertSourceText("x"); // Now check that the "Jump to page" feature works indeed. String jumpToPageTitleXPath = "//div[@class = 'xdialog-title' and starts-with(., 'Go to:')]"; assertElementNotPresent(jumpToPageTitleXPath); getSourceTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g")); assertElementPresent(jumpToPageTitleXPath); // Ctrl+G is a shortcut for "Find again" on Firefox and it opens the find toolbar at the bottom of the page. // This toolbar can influence the way Selenium/WebDriver computes the position of the buttons on the page // leading to cases where clicking on a button has no action because the click is performed at a different // location or because Selenium thinks the location is outside of the page. // Close the "Jump to page" dialog, switch back to rich text area and close the find toolbar. getSourceTextArea().sendKeys(Keys.ESCAPE); switchToWysiwyg(); getRichTextArea().sendKeys(Keys.chord(Keys.CONTROL, "g"), Keys.ESCAPE); }
From source file:stormy.pythian.features.web.steps.TopologyEditionSteps.java
License:Apache License
@Then("^the component \"([^\"]*)\" should have the following properties:$") public void the_component_should_have_the_following_properties(String componentName, DataTable datatable) throws Throwable { connector.click(By.xpath(//from www . jav a 2 s. c om "//*[contains(@class,'diagram-component-title') and contains(text(),'" + componentName + "')]")); connector.click("properties-tab-heading"); List<Property> properties = datatable.asList(Property.class); for (Property property : properties) { String actualValue = components.get_property_value(componentName, property.type, property.name); assertThat(actualValue).isEqualTo(property.value); } connector.press(Keys.ESCAPE); }