Selenium Web驱动程序从jquery datepicker-Ui中选择日期 [英] Selenium web driver selection of date from jquery datepicker-Ui

查看:118
本文介绍了Selenium Web驱动程序从jquery datepicker-Ui中选择日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Selenium Web驱动程序如何选择特定日期字段的jquery datepicker-UI日期. 1)我尝试使用Jscript设置日期.但是,可以从jquery弹出窗口中选择日期,以便获得提交的表单.

How do selenium web driver can select a jquery datepicker-UI date to a particular date field. 1) I have tried using Jscript for setting the date..But however the date msut be selected from the jquery pop up window in order to get the form submitted.

请提出一些自动选择日期并将所选值发布到日期字段的方法.

Please suggest some way to select the date automatically and post the selected value into the date field.

谢谢

推荐答案

    driver.findElement(By.id("datepicker")).clear();
    driver.findElement(By.id("datepicker")).sendKeys("");    // This will add focus and open the Date picker
    String Year = driver.findElement(By.cssSelector("span.ui-datepicker-year")).getText();       //This will give you Year 
    String month = driver.findElement(By.cssSelector("span.ui-datepicker-month")).getText();      //This will give you Month

    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-circle-triangle-e")).click();   // Click for Next Month
    String SelectedDate = driver.findElement(By.cssSelector(".ui-state-highlight")).getText();       // This will get you the selected Date 

    driver.findElement(By.cssSelector("span.ui-icon.ui-icon-circle-triangle-w")).click();      // Click for Previos Month
    driver.findElement(By.linkText("6")).click();   // Instead of 6 use value date which you want to select.

希望这对您有帮助

谢谢
维沙尔

这篇关于Selenium Web驱动程序从jquery datepicker-Ui中选择日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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