使用Selenium WebDriver处理日历 [英] Handle calendar using Selenium WebDriver

查看:188
本文介绍了使用Selenium WebDriver处理日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用带有Java的Selenium WebDriver处理日历元素?我想选择的日期是当前日期+ 5天.请给我建议我该怎么做.我看到日历中包含一个Web表格.

How can I handle the calendar element with Selenium WebDriver with Java? I want to select the date which is the current date + 5 days. Please suggest to me how I can do this. I saw that the calendar contains a webtable.

推荐答案

首先添加5天.然后仅提取日期的整数值和月份的整数值.获得这些值后,您可以轻松选择日期.

First Add 5 days in date. Then extract only integer value of date and integer value of month. Once you have these values you can easily select date.

使用以下代码

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
Calendar c = Calendar.getInstance();
c.setTime(new Date()); // Now use today date.
c.add(Calendar.DATE, 5); // Adding 5 days
String output = sdf.format(c.getTime());
int month = c.get(Calendar.MONTH)+ 1;
int day = c.get(Calendar.DAY_OF_MONTH);
System.out.println("Month : " + month + " day : " + day);

这篇关于使用Selenium WebDriver处理日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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