![](/img/trans.png)
[英]Getting the particular (pre-formatted) text (from a website) using JSoup
[英]Trying to input text into a pre-formatted field does not show the text inputted
我正在嘗試使用硒中的發送鍵功能將出生日期文本發送到輸入字段中。 單擊輸入字段時,輸入字段的正斜杠已預先格式化。
我嘗試使用Javascript執行程序將值設置為“ 07/24/1987”格式,並且確實發送該值。 單擊輸入框后,這些值消失。
這是我必須發送生日的代碼。
WebElement dob = driver.findElement(By.id("userDOB"));
dob.click();
String stringBirthday = "07241987";
char[] charsBirthday = stringBirthday.toCharArray();
for (char ch : charsBirthday) {
String userDob = Character.toString(ch);
dob.sendKeys(userDob);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
因此,我不得不使用Actions類來嘗試復制人類的行為。
Actions actions = new Actions(driver);
actions.moveToElement(dob).click();
actions.sendKeys(bday).perform();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.