blob: 3c850e7fd2998cffc6c0b4c17ab92f2291a71ca9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package com.vaadin.tests.components.textfield;
import static org.junit.Assert.assertEquals;
import org.apache.commons.lang.RandomStringUtils;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class InputPromptGetTextTest extends MultiBrowserTest {
@Test
public void test() {
openTestURL();
WebElement field = getDriver()
.findElement(By.id(InputPromptGetText.FIELD));
WebElement button = getDriver()
.findElement(By.id(InputPromptGetText.BUTTON));
String string = getRandomString();
field.sendKeys(string + "\n");
String selectAll = Keys.chord(Keys.CONTROL, "a");
field.sendKeys(selectAll);
field.sendKeys(Keys.BACK_SPACE);
button.click();
WebElement label = getDriver()
.findElement(By.id(InputPromptGetText.LABEL2));
assertEquals("Your input was:", label.getText().trim());
}
private String getRandomString() {
String string = RandomStringUtils.randomAlphanumeric(3);
return string;
}
}
|