Selenium IDE:如何获取今天的日期? [英] Selenium IDE: How do I get today's date?
本文介绍了Selenium IDE:如何获取今天的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Selenium IDE 测试我的Web应用程序。在某些测试案例中,我必须断言今天的日期出现在页面上。我无法在测试中对今天的日期进行硬编码,因为今天的日期每天都在变化。如何获得当前的日期,月份和日期?是Selenium IDE中的一年?
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 the test because today's date changes every day. How do I get the current day, month & year in Selenium IDE?
推荐答案
不确定日期是什么格式,但是您可以执行以下操作:
Not sure what format your date is in, but you could do something like this:
<tr>
<td>storeEval</td>
<td>var d=new Date(); d.getDate()+'-'+((d.getMonth()+1))
+'-'+d.getFullYear();</td>
<td>date2</td>
</tr>
<tr>
<td>echo</td>
<td>${date2}</td>
<td></td>
</tr>
这篇关于Selenium IDE:如何获取今天的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文