Selenium IDE: How do I get today's date?

前端 未结 5 710
情歌与酒
情歌与酒 2021-02-05 22:16

I\'m testing my web application using Selenium IDE. There are test cases in which I have to assert that today\'s date appears on the page. I cannot hard code today\'s date in th

5条回答
  •  时光说笑
    2021-02-05 23:12

    Double-digits for M and D (i.e. MM/DD/YYYY format):

    var t= new Date(); var d=((t.getDate())<10)?'0'+(t.getDate()):(t.getDate()); var m=((t.getMonth()+1)<10)?'0'+(t.getMonth()+1):(t.getMonth()+1); m+"/"+d+"/"+t.getFullYear();
    

提交回复
热议问题