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:org.natica.expense.ExpenseImport.java
public void importExpenes(List<Expense> expenses, String username, String password) { setUpDriverConfig(ExpenseConstants.WAITSECONDS); openBrowser();/* w ww .j a va 2 s .c om*/ 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.safs.selenium.webdriver.lib.WDLibrary.java
License:Open Source License
/** * Convert a Java KEYCODE to a Selenium WebDriver Keys Enum * @param keycode int, a java keycode// w w w. ja va 2 s . c o m * @return Keys enum for (primarily) non-printable (control) characters, or null. */ public static Keys convertToKeys(int keycode) { Keys key = null; switch (keycode) { case java.awt.event.KeyEvent.VK_ADD: key = Keys.ADD; break; case java.awt.event.KeyEvent.VK_ALT: key = Keys.ALT; break; case java.awt.event.KeyEvent.VK_KP_DOWN: key = Keys.ARROW_DOWN; break; case java.awt.event.KeyEvent.VK_KP_LEFT: key = Keys.ARROW_LEFT; break; case java.awt.event.KeyEvent.VK_KP_RIGHT: key = Keys.ARROW_RIGHT; break; case java.awt.event.KeyEvent.VK_KP_UP: key = Keys.ARROW_UP; break; case java.awt.event.KeyEvent.VK_BACK_SPACE: key = Keys.BACK_SPACE; break; case java.awt.event.KeyEvent.VK_CANCEL: key = Keys.CANCEL; break; case java.awt.event.KeyEvent.VK_CLEAR: key = Keys.CLEAR; break; case java.awt.event.KeyEvent.VK_WINDOWS: key = Keys.COMMAND; break; case java.awt.event.KeyEvent.VK_CONTROL: key = Keys.CONTROL; break; case java.awt.event.KeyEvent.VK_DECIMAL: key = Keys.DECIMAL; break; case java.awt.event.KeyEvent.VK_DELETE: key = Keys.DELETE; break; case java.awt.event.KeyEvent.VK_DIVIDE: key = Keys.DIVIDE; break; case java.awt.event.KeyEvent.VK_DOWN: key = Keys.DOWN; break; case java.awt.event.KeyEvent.VK_END: key = Keys.END; break; case java.awt.event.KeyEvent.VK_ENTER: key = Keys.ENTER; break; case java.awt.event.KeyEvent.VK_EQUALS: key = Keys.EQUALS; break; case java.awt.event.KeyEvent.VK_ESCAPE: key = Keys.ESCAPE; break; case java.awt.event.KeyEvent.VK_F1: key = Keys.F1; break; case java.awt.event.KeyEvent.VK_F2: key = Keys.F2; break; case java.awt.event.KeyEvent.VK_F3: key = Keys.F3; break; case java.awt.event.KeyEvent.VK_F4: key = Keys.F4; break; case java.awt.event.KeyEvent.VK_F5: key = Keys.F5; break; case java.awt.event.KeyEvent.VK_F6: key = Keys.F6; break; case java.awt.event.KeyEvent.VK_F7: key = Keys.F7; break; case java.awt.event.KeyEvent.VK_F8: key = Keys.F8; break; case java.awt.event.KeyEvent.VK_F9: key = Keys.F9; break; case java.awt.event.KeyEvent.VK_F10: key = Keys.F10; break; case java.awt.event.KeyEvent.VK_F11: key = Keys.F11; break; case java.awt.event.KeyEvent.VK_F12: key = Keys.F12; break; case java.awt.event.KeyEvent.VK_HELP: key = Keys.HELP; break; case java.awt.event.KeyEvent.VK_HOME: key = Keys.HOME; break; case java.awt.event.KeyEvent.VK_INSERT: key = Keys.INSERT; break; case java.awt.event.KeyEvent.VK_LEFT: key = Keys.LEFT; break; case java.awt.event.KeyEvent.VK_META: key = Keys.META; break; case java.awt.event.KeyEvent.VK_MULTIPLY: key = Keys.MULTIPLY; break; case java.awt.event.KeyEvent.VK_NUMPAD0: key = Keys.NUMPAD0; break; case java.awt.event.KeyEvent.VK_NUMPAD1: key = Keys.NUMPAD1; break; case java.awt.event.KeyEvent.VK_NUMPAD2: key = Keys.NUMPAD2; break; case java.awt.event.KeyEvent.VK_NUMPAD3: key = Keys.NUMPAD3; break; case java.awt.event.KeyEvent.VK_NUMPAD4: key = Keys.NUMPAD4; break; case java.awt.event.KeyEvent.VK_NUMPAD5: key = Keys.NUMPAD5; break; case java.awt.event.KeyEvent.VK_NUMPAD6: key = Keys.NUMPAD6; break; case java.awt.event.KeyEvent.VK_NUMPAD7: key = Keys.NUMPAD7; break; case java.awt.event.KeyEvent.VK_NUMPAD8: key = Keys.NUMPAD8; break; case java.awt.event.KeyEvent.VK_NUMPAD9: key = Keys.NUMPAD9; break; case java.awt.event.KeyEvent.VK_PAGE_DOWN: key = Keys.PAGE_DOWN; break; case java.awt.event.KeyEvent.VK_PAGE_UP: key = Keys.PAGE_UP; break; case java.awt.event.KeyEvent.VK_PAUSE: key = Keys.PAUSE; break; case java.awt.event.KeyEvent.VK_RIGHT: key = Keys.RIGHT; break; case java.awt.event.KeyEvent.VK_SEMICOLON: key = Keys.SEMICOLON; break; case java.awt.event.KeyEvent.VK_SEPARATOR: key = Keys.SEPARATOR; break; case java.awt.event.KeyEvent.VK_SHIFT: key = Keys.SHIFT; break; case java.awt.event.KeyEvent.VK_SPACE: key = Keys.SPACE; break; case java.awt.event.KeyEvent.VK_SUBTRACT: key = Keys.SUBTRACT; break; case java.awt.event.KeyEvent.VK_TAB: key = Keys.TAB; break; case java.awt.event.KeyEvent.VK_UP: key = Keys.UP; break; } return key; }
From source file:org.vaadin.testbenchsauce.BaseTestBenchTestCase.java
protected void selectMultiSelectOptionByIndex(String caption, int listSelectIndex) { logStep.info("Setting multi-select with caption: " + caption + " to index: " + listSelectIndex); //Chrome driver and ghost driver don't support clicking multi selects well (on change isn't fired)- bug reports - due to https://code.google.com/p/chromedriver/issues/detail?id=496&q=select&colspec=ID%20Status%20Pri%20Owner%20Summary and https://code.google.com/p/chromedriver/issues/detail?id=169#c9 //Workaround is to arrow down to the item (which does trigger the on change logic) WebElement selectElement = getSelectElement(caption); assertNotNull("Could not find the multi-select field '" + caption + "'.", selectElement); selectElement.sendKeys(Keys.HOME); for (int i = 0; i < listSelectIndex; i++) { selectElement.sendKeys(Keys.ARROW_DOWN); }/*from w w w. j a v a2 s .co m*/ }
From source file:org.xmlium.test.web.commons.xml.XMLTestSteps.java
License:LGPL
protected void processStep(StepType step) throws Exception { WebElement element = null;/*from ww w .j a va 2 s . co m*/ Alert a = null; if (step.getScrollX() != null && step.getScrollY() != null) { JavascriptExecutor js = (JavascriptExecutor) getSuite().getDriver(); js.executeScript("window.scrollTo(" + step.getScrollX() + ", " + step.getScrollY() + ");"); } if (step.isBack() != null && step.isBack()) { getSuite().getDriver().navigate().back(); } if (step.isForward() != null && step.isForward()) { getSuite().getDriver().navigate().forward(); } Element e = null; if (step.getLoad() != null && step.getLoad().getKey() != null) { e = store.get(step.getLoad().getKey()); element = findElement(e.getFinds()); } if (step.getElement() != null) { if (step.getElement().getFinds() != null) { e = step.getElement(); checkStore(e); element = checkWaitFor(e); if (element == null && step.getElement().isCheckNullElement()) { return; } checkStoreValue(e, element); checkSetValue(e, element); checkSendKeys(e, element); checkClick(e, element); checkChangeState(e); checkText(e, element); checkMoveX(e, element); } } if (step.getSwitchTo() != null) { Object to = switchTo(step.getSwitchTo()); if (to instanceof Alert) { a = (Alert) to; if (step.getSwitchTo().getAlert() != null && step.getSwitchTo().getAlert().isAccept()) { a.accept(); } } else { a = null; } } if (step.getSelect() != null) { org.xmlium.testsuite.Select stepSelect = step.getSelect(); if (element != null && stepSelect.getSelectBy().getByIndex() != null) { Index index = stepSelect.getSelectBy().getByIndex(); SelectData selectData = new SelectData(); initSelectIndexes(element, index, selectData); if (selectData.selectIndex >= 0) { Select select = new Select(element); List<WebElement> options = select.getOptions(); WebElement option = options.get(selectData.selectIndex); option.click(); } else { throw new RuntimeException("selectedIndex=" + selectData.selectIndex); } } else { if (element == null) { element = findElement(step.getSelect().getFinds()); } if (element != null) { Select select = new Select(element); if (step.getSelect().getSelectBy() != null) { selectBy(select, step.getSelect().getSelectBy()); } } } } if (step.getPrettySelect() != null) { PrettySelect stepSelect = step.getPrettySelect(); if (element == null) { if (stepSelect.getFinds() != null) { element = findElement(stepSelect.getFinds()); } } if (element != null && stepSelect.getSelectBy() != null) { SelectData selectData = new SelectData(); Select select = null; select = new Select(element); Index index = null; if (stepSelect.getSelectBy().getByIndex() != null) { index = stepSelect.getSelectBy().getByIndex(); initSelectIndexes(element, index, selectData); } else if (stepSelect.getSelectBy().getByVisibleText() != null) { List<WebElement> elems = select.getOptions(); getOptionIndexBuVisibleText(stepSelect.getSelectBy().getByVisibleText(), elems, selectData); } if (selectData.selectIndex >= 0) { WebElement arrowArea = null; WebElement scrollArea = null; if (stepSelect.getSelectBy().getArrowArea() != null) { arrowArea = findElement(stepSelect.getSelectBy().getArrowArea()); } else { throw new RuntimeException("arrowArea not defined in xml"); } if (arrowArea != null) { arrowArea.click(); if (stepSelect.getSelectBy().getScrollArea() != null) { Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea(); if (scrollAreaFinds.getFind() != null) { scrollArea = findElement(scrollAreaFinds.getFind()); } else if (scrollAreaFinds.getWaitFor() != null) { scrollArea = waitFor(scrollAreaFinds.getWaitFor()); } if (scrollArea == null) { if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) { String text = ""; if (scrollAreaFinds.getFind() != null && scrollAreaFinds.getFind().getByXPath() != null) { text = unformatValue(scrollAreaFinds.getFind().isUnformat(), scrollAreaFinds.getFind().getByXPath().getValue()); } else if (scrollAreaFinds.getWaitFor() != null && scrollAreaFinds.getWaitFor().getByXPath() != null) { text = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(), scrollAreaFinds.getWaitFor().getByXPath().getValue()); } throw new RuntimeException("scrollArea not found: " + text); } else { throw new RuntimeException("scrollArea not defined in xml"); } } } if (index.isFirst() != null || index.isLast() != null) { Actions actions = new Actions(getSuite().getDriver()); String text = null; if (index.isFirst() != null && index.isFirst()) { actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform(); } else if (index.isLast() != null && index.isLast()) { actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform(); } if (index.isFirst() != null && index.isFirst()) { text = select.getOptions().get(0).getText(); } else if (index.isLast() != null && index.isLast()) { text = select.getOptions().get(select.getOptions().size() - 1).getText(); } if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null && !text.isEmpty()) { xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); WebElement optionElemnt = findElement(f); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(optionElemnt)); optionElemnt.click(); } } else { if (selectData.selectIndex < 0 || selectData.selectIndex >= select.getOptions().size()) { throw new RuntimeException("selectIndex: " + selectData.selectIndex + ", options.size: " + select.getOptions().size()); } WebElement option = select.getOptions().get(selectData.selectIndex); String text = option.getText(); if (text == null || text.isEmpty()) { logger.debug("text is null or empty: " + option); text = null; } if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null) { xPath.setValue("//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); WebElement optionElemnt = findElement(f); Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates(); coordinate.onPage(); coordinate.inViewPort(); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(optionElemnt)); optionElemnt.click(); } } } else { throw new RuntimeException("can't click the arrow"); } } else if (stepSelect.getSelectBy().getByVisibleText() != null) { WebElement arrowArea = null; WebElement scrollArea = null; if (stepSelect.getSelectBy().getArrowArea() != null) { arrowArea = findElement(stepSelect.getSelectBy().getArrowArea()); } else { throw new RuntimeException("arrowArea not defined in xml"); } if (arrowArea != null) { arrowArea.click(); String scrollAreaXPath = null; if (stepSelect.getSelectBy().getScrollArea() != null) { Finds scrollAreaFinds = stepSelect.getSelectBy().getScrollArea(); if (scrollAreaFinds.getFind() != null) { scrollArea = findElement(scrollAreaFinds.getFind()); } else if (scrollAreaFinds.getWaitFor() != null) { scrollArea = waitFor(scrollAreaFinds.getWaitFor()); } if (scrollAreaXPath == null) { if (scrollAreaFinds.getFind() != null || scrollAreaFinds.getWaitFor() != null) { if (scrollAreaFinds.getFind() != null && scrollAreaFinds.getFind().getByXPath() != null) { scrollAreaXPath = unformatValue(scrollAreaFinds.getFind().isUnformat(), scrollAreaFinds.getFind().getByXPath().getValue()); } else if (scrollAreaFinds.getWaitFor() != null && scrollAreaFinds.getWaitFor().getByXPath() != null) { scrollAreaXPath = unformatValue(scrollAreaFinds.getWaitFor().isUnformat(), scrollAreaFinds.getWaitFor().getByXPath().getValue()); } // throw new RuntimeException("scrollArea // not found: " + text); } else { throw new RuntimeException("scrollArea not defined in xml"); } } } Actions actions = new Actions(getSuite().getDriver()); String text = null; // actions.keyDown(Keys.CONTROL).sendKeys(Keys.HOME).perform(); WebDriverWait wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.elementToBeClickable(scrollArea)); actions.moveToElement(scrollArea).build().perform(); text = stepSelect.getSelectBy().getByVisibleText(); logger.debug("text: " + text); if (stepSelect.getSelectBy().getOptionsTag() != null) { Find f = new Find(); ByXPath xPath = new ByXPath(); if (text != null) { xPath.setValue(scrollAreaXPath + "/descendant::" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "') and text()='" + text + "']"); } else { xPath.setValue("(//" + stepSelect.getSelectBy().getOptionsTag() + "[contains(@class, '" + stepSelect.getSelectBy().getOptionsClasses() + "')])[" + Integer.toString(selectData.selectIndex + 1) + "]"); } f.setByXPath(xPath); logger.debug("xPath: " + xPath); WebElement optionElemnt = findElement(f); Coordinates coordinate = ((Locatable) optionElemnt).getCoordinates(); coordinate.onPage(); coordinate.inViewPort(); wait = new WebDriverWait(getSuite().getDriver(), 30); wait.until(ExpectedConditions.visibilityOf(optionElemnt)); actions.moveToElement(optionElemnt).click().build().perform(); } } } else { throw new RuntimeException("selectedIndex=" + selectData.selectIndex); } } else { if (element == null) { element = findElement(step.getPrettySelect().getFinds()); } if (element != null) { Select select = new Select(element); if (step.getPrettySelect().getSelectBy() != null) { selectBy(select, step.getPrettySelect().getSelectBy()); } } } } if (step.getSleepAfter() != null) { long sleep = step.getSleepAfter().longValue(); try { Thread.sleep(sleep); } catch (Exception e2) { // TODO: handle exception } } }
From source file:org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage.java
License:Open Source License
/** * Drags a field of the specified type from the field palette to the field canvas. * /* w ww.jav a 2s . co m*/ * @param fieldType the type of field to add, as displayed on the field palette */ public ClassFieldEditPane addField(String fieldType) { String fieldXPath = "//span[@class = 'field' and normalize-space(.) = '%s']"; WebElement field = palette.findElement(By.xpath(String.format(fieldXPath, fieldType))); // NOTE: We scroll the page up because the drag&drop fails sometimes if the dragged field and the canvas (drop // target) are not fully visible. See https://code.google.com/p/selenium/issues/detail?id=3075 . palette.sendKeys(Keys.HOME); new Actions(getDriver()).dragAndDrop(field, fieldsCanvas).perform(); final WebElement addedField = fieldsCanvas.findElement(By.xpath("./ul[@id='fields']/li[last()]")); getUtil().waitUntilCondition(new ExpectedCondition<Boolean>() { @Override public Boolean apply(WebDriver driver) { try { return !addedField.getAttribute("class").contains("loading"); } catch (NotFoundException e) { return false; } catch (StaleElementReferenceException e) { // The element was removed from DOM in the meantime return false; } } }); return new ClassFieldEditPane(addedField.getAttribute("id").substring("field-".length())); }
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. *//*w ww . j a v a2s. co 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 w w w . ja v a 2 s . co m @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)); }