問(wèn)題描述
我想更新一些 HTML5 日期表單字段的日期值(顯示為 mm/dd/yyyy,僅數(shù)字部分可修改):
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"/>
在我的 Selenium/Protractor 測(cè)試中.我已經(jīng)嘗試為此使用 sendKeys
但(在 Chrome 上)到目前為止還沒(méi)有成功.
in my Selenium/Protractor tests. I've tried using sendKeys
for this but (on Chrome) have not been successful so far.
有沒(méi)有辦法使用 sendKeys
做到這一點(diǎn)?還是有其他方法?
Is there a way to do this using sendKeys
? Or some other way to do it?
推薦答案
在 Mac 上使用 Chrome 和 Protractor,以下方法對(duì)我有用.
Using Chrome on Mac with Protractor, the following approach has worked for me.
模板 (html5)
<input type="date" placeholder="Due Date" ng-model="newLesson.dueDate">
測(cè)試
this.newLessonDate = element( by.model('newLesson.dueDate') );
this.newLessonDate.sendKeys('01-30-2015');
在我輸入日期格式為01-30-2015"之前,我一直收到錯(cuò)誤.
I kept getting errors until I entered the date format as '01-30-2015'.
這篇關(guān)于如何設(shè)置 HTML5 type="date";使用 Selenium/Protractor 的輸入字段(例如在 Chrome 中)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!