List of usage examples for org.openqa.selenium Keys PAGE_UP
Keys PAGE_UP
To view the source code for org.openqa.selenium Keys PAGE_UP.
Click Source Link
From source file:org.testeditor.fixture.web.RapWebFixture.java
License:Open Source License
/** * Selects an option from an available drop down element by the visible * text.//from ww w . j a v a 2 s. c om * * <p/> * <b>Hint:</b> Doesn't work for drop down lists with duplicate entries. * * @param value * the value to select * @param elementListKey * key in the element list to find the technical locator * @param replaceArgs * values to replace the place holders in the element list entry * @return {@code true} if the {@code value} was selectable, {@code false} * otherwise * @throws StopTestException * if element not available (hidden, not present) or a timeout * occurred */ public boolean selectOption(String value, String elementListKey, String... replaceArgs) throws StopTestException { /* * Because RAP doesn't render drop downs as select-tags with options, we * can't use the standard web driver Select-class. RAP creates combo * boxes as input field with attached divs. Input field and divs don't * share a common XPATH. */ boolean result = false; WebElement element = findAvailableWebElement(elementListKey, replaceArgs); element.click(); // start on top of the list element.sendKeys(Keys.DOWN); element.sendKeys(Keys.PAGE_UP); String currentValue = element.getAttribute("value"); String before = null; do { if (value.equals(currentValue)) { element.click(); result = true; } else { before = currentValue; // go on to the next element in the list element.sendKeys(Keys.DOWN); currentValue = element.getAttribute("value"); } // stop execution, if last and current analyzed value are the same } while (!currentValue.equals(before) && !result); return result; }
From source file:org.xwiki.test.wysiwyg.TabsTest.java
License:Open Source License
/** * Switches to source tab while the rich text area is still loading. The source text must remain unchanged. *//*ww w . jav a 2s. c o m*/ @Test public void testSwitchToSourceWhileWysiwygIsLoading() { switchToSource(); StringBuffer sourceText = new StringBuffer(); sourceText.append("{{code language=\"java\"}}\n"); sourceText.append("public interface Command {\n"); sourceText.append(" boolean execute(String parameter);\n"); sourceText.append("}\n"); sourceText.append("{{/code}}"); setSourceText(sourceText.toString()); // Set the cursor position before "language" to see if it is preserved. getSourceTextArea().sendKeys(Keys.HOME, Keys.PAGE_UP, Keys.chord(Keys.CONTROL, Keys.ARROW_RIGHT), Keys.ARROW_RIGHT); // Switch to WYSIWYG tab but don't wait for the rich text area to load. switchToWysiwyg(false); // Switch back to source tab. switchToSource(); getSourceTextArea().sendKeys("x"); // Check the source text. We don't assert the cursor position directly because it isn't available when the test // is run in background. assertSourceText(sourceText.substring(0, 7) + "x" + sourceText.substring(7)); }
From source file:org.xwiki.test.wysiwyg.TabsTest.java
License:Open Source License
/** * Tests if the switch to WYSIWYG tab action can be canceled. *///from www .ja v a2s . com @Test public void testCancelSwitchToWysiwyg() { // Switch to source tab and insert some content that takes time to render. A code macro is perfect for this. switchToSource(); StringBuilder sourceText = new StringBuilder(); sourceText.append("{{code language=\"java\"}}\n"); sourceText.append("public final class Apple extends Fruit {\n"); sourceText.append(" public String getColor() {\n"); sourceText.append(" return \"red\";\n"); sourceText.append(" }\n"); sourceText.append("}\n"); sourceText.append("{{/code}}"); setSourceText(sourceText.toString()); // Place the caret before "Apple". getSourceTextArea().sendKeys(Keys.HOME, Keys.PAGE_UP, Keys.ARROW_DOWN, Keys.chord(Keys.CONTROL, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT), Keys.ARROW_RIGHT); // Switch to rich text but don't wait till the rich text area finishes loading. switchToWysiwyg(false); // Switch back to source before the rich text area is reloaded. switchToSource(); // Change the content. getSourceTextArea().sendKeys("X"); // Switch to WYSIWYG tab again, this time with a different source text. Wait for the rich text area to load. switchToWysiwyg(); // Check the result. switchToSource(); getSourceTextArea().sendKeys("Y"); assertSourceText(sourceText.substring(0, 44) + "XY" + sourceText.substring(44)); }