首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sendKeys不工作IE

sendKeys不工作IE
EN

Stack Overflow用户
提问于 2013-10-21 15:28:11
回答 2查看 7.7K关注 0票数 1

我在一个网站上有三个字段,我正在用joda time填充这些字段。在Firefox中,一切都很好。然而,在IE中,IRB过期日期字段被填充,开始日期和结束日期字段没有填充。有什么想法吗?这是和IE9的。我已经更新了最新版本的joda,现在还没有得到joy。我已经将WebDriver和IEDriver更新为2.37。当我把它发送到控制台时,时间被正确地输出了。

代码语言:javascript
复制
//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);
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-10-25 06:58:27

解决方案:试用Actions ClasssendKeys()方法:

代码语言:javascript
复制
Actions action = new Actions(driver);
action.sendKeys(yourElement, textToEnter).build().perform();

注意事项: IE中的主要是随机打印一半或单个字符。通过上面的解,我们可以解决这个问题。

票数 3
EN

Stack Overflow用户

发布于 2013-10-25 04:31:36

我可以想到两种情况:

1.)确保您能够选择和集中在上的元素。有时,在输入元素之前,您可能需要将重点放在元素上。因此,尝试使用此方法将重点放在元素上(仅举一个例子)

代码语言:javascript
复制
    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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19498667

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档