From 472433f614cdf4db1456542432abf66947335354 Mon Sep 17 00:00:00 2001 From: Alexander Kedrik Date: Wed, 23 Jul 2014 21:18:22 +0400 Subject: [PATCH 1/4] fix issue #65 --- .../qatools/htmlelements/element/Form.java | 18 ++++++++++++++---- .../htmlelements/testelements/MockedForm.java | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/htmlelements-java/src/main/java/ru/yandex/qatools/htmlelements/element/Form.java b/htmlelements-java/src/main/java/ru/yandex/qatools/htmlelements/element/Form.java index 450f8e9d..ba6a4a8a 100644 --- a/htmlelements-java/src/main/java/ru/yandex/qatools/htmlelements/element/Form.java +++ b/htmlelements-java/src/main/java/ru/yandex/qatools/htmlelements/element/Form.java @@ -1,6 +1,8 @@ package ru.yandex.qatools.htmlelements.element; +import org.apache.commons.lang3.StringUtils; import org.openqa.selenium.By; +import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import java.util.List; @@ -68,23 +70,31 @@ protected void fillElement(WebElement element, Object value) { if (isInput(element)) { String inputType = element.getAttribute("type"); - if (inputType == null || inputType.equals(TEXT_INPUT_TYPE) || inputType.equals(PASSWORD_INPUT_TYPE)) { - element.sendKeys(value.toString()); - } else if (inputType.equals(CHECKBOX_TYPE)) { + if (inputType.equals(CHECKBOX_TYPE)) { CheckBox checkBox = new CheckBox(element); checkBox.set(Boolean.parseBoolean(value.toString())); } else if (inputType.equals(RADIO_TYPE)) { Radio radio = new Radio(element); radio.selectByValue(value.toString()); + } else { + element.sendKeys(getClearTextInputElementCharSequence(element) + value.toString()); } } else if (isSelect(element)) { Select select = new Select(element); select.selectByValue(value.toString()); } else if (isTextArea(element)) { - element.sendKeys(value.toString()); + element.sendKeys(getClearTextInputElementCharSequence(element) + value.toString()); } } + // Returns sequence of backspaces and deletes that will clear element + // element.clear() can't be used because clear() generates separate onchange event + // element must be