Skip to content

Commit

Permalink
should be able to send keys to a content editable div that is initial…
Browse files Browse the repository at this point in the history
…ly empty

Fixes #1165
  • Loading branch information
lukeis committed Oct 16, 2015
1 parent 5eca824 commit 08eb846
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions common/src/web/readOnlyPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
text area which is not supposed to be cleared</textarea>

<div id="content-editable" contentEditable="true">This is a contentEditable area</div>

<div id="content-editable-blank" contentEditable="true" style="height:50px;"></div>
</body>
</html>

5 changes: 2 additions & 3 deletions java/client/test/org/openqa/selenium/TypingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,9 @@ public void testShouldBeAbleToTypeOnANumberInputField() {
@Test
public void testShouldBeAbleToTypeIntoEmptyContentEditableElement() {
driver.get(pages.readOnlyPage);
WebElement editable = driver.findElement(By.id("content-editable"));
WebElement editable = driver.findElement(By.id("content-editable-blank"));

editable.clear();
editable.sendKeys("cheese"); // requires focus on OS X
editable.sendKeys("cheese");

assertThat(editable.getText(), equalTo("cheese"));
}
Expand Down
2 changes: 1 addition & 1 deletion javascript/firefox-driver/js/wrappedElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ WebElement.sendKeysToElement = function(respond, parameters) {
if (!alreadyFocused && bot.dom.isEditable(element)) {
var length = element.value ? element.value.length : goog.dom.getTextContent(element).length;

if (bot.dom.isContentEditable(element)) {
if (bot.dom.isContentEditable(element) && length) {
var doc = element.ownerDocument || element.document;
var rng = doc.createRange();
var walker = doc.createTreeWalker(element, 4/*NodeFilter.SHOW_TEXT*/, null, null);
Expand Down

0 comments on commit 08eb846

Please sign in to comment.