我在一个网站上有三个字段,我正在用joda time填充这些字段。在Firefox中,一切都很好。然而,在IE中,IRB过期日期字段被填充,开始日期和结束日期字段没有填充。有什么想法吗?这是和IE9的。我已经更新了最新版本的joda,现在还没有得到joy。我已经将WebDriver和IEDriver更新为2.37。当我把它发送到控制台时,时间被正确地输出了。
//Enter an IRB Expiration Date - This is the one which works
WebElement irbExpCP = driver.findElement(By.id("irbExpDate"));
irbExpCP.click();
LocalDate irbDate = LocalDate.now().plusYears(5);
DateTimeFormatter formatter = DateTimeFormat.forPattern("MM/dd/yyyy");
String irbDate2 = formatter.print(irbDate);
irbExpCP.sendKeys(irbDate2);
//Enter a Start Date
WebElement startDateCP = driver.findElement(By.id("startDate"));
startDateCP.click();
LocalDate startDate = LocalDate.now();
String startDate2 = formatter.print(startDate);
startDateCP.sendKeys(startDate2);
//Enter an End Date
WebElement endDateCP = driver.findElement(By.id("endDate"));
endDateCP.click();
LocalDate endDate = LocalDate.now().plusYears(10);
String endDate2 = formatter.print(endDate);
endDateCP.sendKeys(endDate2);发布于 2013-10-25 06:58:27
解决方案:试用Actions Class和sendKeys()方法:
Actions action = new Actions(driver);
action.sendKeys(yourElement, textToEnter).build().perform();注意事项: IE中的主要是随机打印一半或单个字符。通过上面的解,我们可以解决这个问题。
发布于 2013-10-25 04:31:36
我可以想到两种情况:
1.)确保您能够选择和集中在上的元素。有时,在输入元素之前,您可能需要将重点放在元素上。因此,尝试使用此方法将重点放在元素上(仅举一个例子)
driver.findElement(By.id("myid")).click();
driver.findElement(By.id("myid")).sendKeys("text");如果是这样的话,这应该会很好。
2.)其他情况下,我的原因是IEDriver体系结构。我有core i5,正在尝试IEDriver for 64 bit,这导致了几个问题(就像sendkey在绑下一个字母之前3到4秒很慢地工作)。因此,如果是这样的话,只需尝试更改IEDriver。
https://stackoverflow.com/questions/19498667
复制相似问题