【问题标题】:Entered Text is removed from Date text field using Selenium使用 Selenium 从日期文本字段中删除输入的文本
【发布时间】:2017-08-15 18:29:57
【问题描述】:

我正在尝试使用 sendkeys 在日期文本字段中输入日期,但是一旦焦点从它移开,文本就会消失。 HTML ;

 <div class="v-datefield v-datefield-popupcalendar v-widget v-datefield-day">
<input id="gwt-uid-109" class="v-textfield v-datefield-textfield" type="text" aria-describedby="gwt-uid-105" aria-controls="gwt-uid-106" aria-labelledby="gwt-uid-108" tabindex="0"/>

我已尝试发送密钥 getElement(locator).sendKeys(expectedValue);

【问题讨论】:

  • 您还面临这个问题吗?你能提供更多的 HTML DOM 吗?

标签: javascript java selenium selenium-webdriver


【解决方案1】:

该字段的编程方式是,如果您在日期字段之外按 Tab,则该值将重置为“”

如果我可以建议,请手动尝试,看看它是否具有相同的行为。 要通过 sselenium 来解决这个问题: 尝试这个: • 第一个 DatefieldElement.Clear(); • 然后 DateFielsElement.SendKeys(value) • 然后使用Robot API 敲回车键

Robot rob = new Robot
Thread.sleep(500);
rob.keyPress(KeyEvent.VK_ENTER)

【讨论】:

  • 猜猜你应该使用 DatePicker 然后 - @UmeshKumar
猜你喜欢
  • 2013-10-09
  • 1970-01-01
  • 2013-10-08
  • 2011-04-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-14
相关资源
最近更新 更多