chromewebdriver 上的清除日期输入失败 [英] Clear date input fails on chromewebdriver

查看:16
本文介绍了chromewebdriver 上的清除日期输入失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 selenium 从 firefoxdriver 切换到 chromedriver 时遇到问题,它在 FF 中运行良好,但现在当我尝试清除日期输入字段时出现此错误:

I ran into a problem while switching from firefoxdriver to chromedriver with selenium, it was working fine in FF but now when I try to clear a date input field I have this error:

Caused by: org.openqa.selenium.InvalidElementStateException: Element must be user-editable
in order to clear it. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 38 milliseconds
Build info: version: '2.31.0', revision: '1bd294d185a80fa4206dfeab80ba773c04ac33c0',
time: '2013-02-27 13:51:26'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: 
'1.6.0_41'
Session ID: cb5a1b7e5f4abc4f2e56e2fe284a9dc3
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=MAC, chrome.chromedriverVersion=26.0.1383.0, acceptSslCerts=false,
javascriptEnabled=true, browserName=chrome, rotatable=false, locationContextEnabled=false,
version=25.0.1364.160, cssSelectorsEnabled=true, databaseEnabled=false, 
handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true,
webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
blah blah...

我尝试将 contenteditable 属性添加到我的输入字段但没有运气:

I tried adding the contenteditable attribute to my input fields but no luck there:

  <input type="date" contenteditable="true" required="required" placeholder="YYYY-MM-dd" />

我不确定是否应该报告或在哪里报告,但我发现相关项目中的这些问题有些相似:

I am not sure if I should report that or where to report it but I found these issues in related projects that somewhat similar:

https://github.com/jnicklas/capybara/issues/554

https://github.com/Behat/MinkSelenium2Driver/pull/29

与此同时,有什么建议可以解决这个错误吗?

In the meantime any suggestions to get around that bug?

推荐答案

作为一种解决方法,您可以选择表示输入字段的 webElement 并执行

As a workaround you can select the webElement representing the input field and perform a

webElement.SendKeys(Keys.Delete);

清除字段.

这篇关于chromewebdriver 上的清除日期输入失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆