如何使用量角器从日历中选择今天的日期 [英] How to Select today's date from a calender using Protractor

查看:174
本文介绍了如何使用量角器从日历中选择今天的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在量角器中写一个脚本,我在一个角度应用程序中有一个日历。

I'm writing a script in Protractor and I have a calendar in my angular application.

我使用了元素(by.css('今天的日期'))click(); 日期从日历。但是,我必须每天更改代码以选择今天的日期。

I used element(by.css('Today's date')).click(); to select today's date from the calender. But, I have to change the code everyday to select the today's date.

那么,从日历中选择今天的日期有没有具体要求?

So, Is there a specific anyway to select the today's date from the calendar?

谢谢。 :)

推荐答案

使用以下代码。

 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);

有关详情,请参阅 alecxe 的回答在这里

For more information look at alecxe's answer here.

希望这有助于。 :)

这篇关于如何使用量角器从日历中选择今天的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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