【问题标题】:How to sendvalue into date field using selenium如何使用硒将值发送到日期字段
【发布时间】:2019-07-31 02:13:49
【问题描述】:

使用 SendKeys 方法,日期字段不接受输入。已尝试通过单击该字段并发送值。但还是失败了

IwebElement StartDate = driver.findElement(By.name("inpR8C3L8"));
StartDate.click();
Startdate.sendkeys("010119");

这里是html:

<input type="text" class="wpsEditField" style="color: green;" size="8" maxlength="8" name="inpR8C3L8" value=" 0/00/00" tabindex="101" onfocus="javascript: iwaJSR168_5250SetCurrentInputField(this);">

我如何使用 javascript 实现这一点?

【问题讨论】:

    标签: javascript c# selenium-webdriver


    【解决方案1】:

    您可以使用 IJavascriptExecutor 通过 javascript 向您的元素发送文本。

    IJavascriptExecutor jse = (IJavascriptExecutor) driver;
    jse.executeScript("arguments[0].value='010119';",StartDate);
    

    argument[0] 是元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      • 2018-10-23
      • 1970-01-01
      • 2020-08-13
      • 1970-01-01
      相关资源
      最近更新 更多