-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add TextInput.setText #90
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,15 @@ public void sendKeys(CharSequence... keys) { | |
getWrappedElement().sendKeys(keys); | ||
} | ||
|
||
/** | ||
* Sets this text input's value. | ||
* | ||
* @param newValue New value for this text input. | ||
*/ | ||
public void setText(String newValue) { | ||
getWrappedElement().sendKeys(getClearCharSequence() + newValue); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think instead the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would break backward compatibility and would be counterintuitive. |
||
} | ||
|
||
/** | ||
* @return Text entered into the text input. | ||
* @deprecated Use getText() instead. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package ru.yandex.qatools.htmlelements; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.Keys; | ||
import org.openqa.selenium.WebElement; | ||
import ru.yandex.qatools.htmlelements.element.TextInput; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* @author Alexander Kedrik [email protected] | ||
* Date: 08.09.15 | ||
*/ | ||
public class TextInputSetTextMethodTest { | ||
private final WebElement webElement = mock(WebElement.class); | ||
private final TextInput textInput = new TextInput(webElement); | ||
|
||
@Test | ||
public void setTextShouldNotAddClearKeysForTextInputWithEmptyText() { | ||
when(webElement.getAttribute("value")).thenReturn(""); | ||
textInput.setText("qwerty"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is assertion for this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
verify(webElement).sendKeys("qwerty"); | ||
} | ||
|
||
@Test | ||
public void setTextShouldAddClearKeysForTextInputWithNonEmptyText() { | ||
when(webElement.getAttribute("value")).thenReturn("12"); | ||
textInput.setText("qwerty"); | ||
verify(webElement).sendKeys(Keys.DELETE.toString() + Keys.BACK_SPACE + Keys.DELETE + Keys.BACK_SPACE + "qwerty"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps be explicit about using
getClearCharSequence()
and not usingclear()
?