【问题标题】:How to check current date and move to next date in selenium webdriver using java如何使用java在selenium webdriver中检查当前日期并移至下一个日期
【发布时间】:2019-02-20 05:50:58
【问题描述】:

我的脚本遇到问题。我想检查引导日历中的日期。我想从引导日历中检查今天的日期,需要检查航班是否可用。如果当天有航班,将进行进一步的处理。如果没有,则弹出消息将通过航班不可用。这是简单的条件如果我使用引导日历检查当前日期的航班可用性。 但我想检查今天的航班是否不存在,然后用户可以前往下一个可用日期搜索航班,如果可用,则进一步处理。但我无法做到这一点。 这是我写的代码:

    WebElement current_day=d.findElement(By.xpath("//tr/td[@class='day today']"));
    String today_day=current_day.getText();
    int today_day_in=Integer.parseInt(today_day);
    System.out.println("Today date:  "+today_day_in);
    for(int i=today_day_in;i<=31;i++)
    {
        if(all==i)
                {
                   mod.click(current_day);
                }
        else
        {
            System.out.println("erorr");
        }
    }

【问题讨论】:

    标签: java selenium calendar


    【解决方案1】:

    对于当前日期,您需要使用此方法

    public static void getCurrentTime(){
         System.out.println("-----Current time of your time zone-----");
         LocalTime time = LocalTime.now();
         System.out.println("Current time of the day: " + time);
     }
    

    【讨论】:

    • 好的。但是如果我想检查下一个可用日期并检查航班是否可用,如果没有,则再次搜索下一个日期。就像那样,如果我想迭代如何做到这一点?我没有得到。
    • 基于您必须为可用编写该逻辑,您能否仅显示两个屏幕截图和航班可用和不可用的来源..
    • 对不起,我无法上传截图。
    猜你喜欢
    • 2019-07-09
    • 2014-07-01
    • 2016-04-05
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 2013-04-29
    • 2022-01-24
    相关资源
    最近更新 更多