如何使用量角器编写日历e2e案例?

时间:2016-04-28 00:23:34

标签: calendar protractor

我是使用量角器的新手,现在我正在为一个页面编写一个测试用例。你能帮我看看如何获​​取日历活动并检索日期和时间吗?我非常感谢您的帮助。

以下是视图:

//from when and what time you want to take vacation
        <div>
            <label class="control-label " for="startDate">Start Date</label>

            <div class="input-group">
                <input type="text" class="form-control ng-valid ng-isolate-scope ng-valid-datetime ng-dirty ng-touched" name="startDate" placeholder="StartDate" datetime-picker="" ng-model="olNew.startDate" default-time="09:00" is-open="open.date3">
                <span class="input-group-btn">
                    <button type="button" class="btn btn-default" ng-click="openCalendar($event, 'date3')"><i class="fa fa-calendar"></i></button>
                </span>
            </div>

        </div>
        //When and at what time you will end vacation
        <div class="form-group ">
            <label class="control-label " for="endDate">
                End Date
            </label>
            <div class="input-group">
                <input type="text" class="form-control ng-valid ng-isolate-scope ng-valid-datetime ng-dirty ng-touched" name="endDate" placeholder="EndDate" datetime-picker="" ng-model="olNew.endDate" default-time="09:30" is-open="open.date4">
                <span class="input-group-btn">
                    <button type="button" class="btn btn-default" ng-click="openCalendar($event, 'date4')"><i class="fa fa-calendar"></i></button>
                </span>
            </div>
        </div>
        <div class="form-group ">
            <label class="control-label " for="totalHours">
                Total Hours
            </label>
            <input class="form-control" id="totalHours" name="totalHours" placeholder="Total Hours" type="text" ng-model="olNew.ioHours"/>
        </div>

Here is the screenshot of the calendar:

1 个答案:

答案 0 :(得分:0)

以下代码可用于测试角度js日历。

var pickerDue = element(by.model("supplier.enroll_date"));

var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
    dd='0'+dd
} 

if(mm<10) {
    mm='0'+mm
} 

today = yyyy+'-'+mm+'-'+dd;

pickerDue.clear();
pickerDue.sendKeys(today);

如果您不清楚,请随时提出任何问题。