如何设置HTML5 type ="date"使用硒/量角器输入字段(例如在Chrome中)? [英] How to set HTML5 type="date" input fields (e.g. in Chrome) using Selenium/Protractor?
问题描述
我想更新某些HTML5日期表单字段的日期值(显示为mm/dd/yyyy,仅可修改数字部分):
I want to update the date value (displayed as mm/dd/yyyy with only the number portions modifiable) of some HTML5 date form fields:
<input type="date"/>
在我的硒/量角器测试中.我已经尝试使用sendKeys
进行此操作,但到目前为止(在Chrome上)尚未成功.
in my Selenium/Protractor tests. I've tried using sendKeys
for this but (on Chrome) have not been successful so far.
是否可以使用sendKeys
执行此操作?还是其他方法?
Is there a way to do this using sendKeys
? Or some other way to do it?
推荐答案
在Mac上使用带有Protractor的Chrome,以下方法对我有效.
Using Chrome on Mac with Protractor, the following approach has worked for me.
模板(html5)
<input type="date" placeholder="Due Date" ng-model="newLesson.dueDate">
测试
this.newLessonDate = element( by.model('newLesson.dueDate') );
this.newLessonDate.sendKeys('01-30-2015');
在输入日期格式为"01-30-2015"之前,我一直出错.
I kept getting errors until I entered the date format as '01-30-2015'.
这篇关于如何设置HTML5 type ="date"使用硒/量角器输入字段(例如在Chrome中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!