首页 > 解决方案 > 没有从日历中选择日期..我已经解决了这个问题。问题已解决

问题描述

我有一个日历,在选择日期时需要单击添加日期的勾号按钮

格式:8/20/2021, 15:28:13

我试过的:

我尝试创建一个方法,如下所示:

public static void selectdatefromcalender(WebDriver driver,String columnKey, Map<String, String> formEntryMap) 
{
        String xPath = Xpath.dateXpathReplace.replace("XXXX", columnKey); 

= 我在这里得到日期字段的标签名称。这是单击日历按钮的 Xpath。

    clickOnElement(driver, xPath);  /**/ This will click on the Calender button and works till this**
        //But is not selecting the value from the Date

    List<WebElement> columns=driver.findElements(By.tagName("td"));

    for (WebElement cell: columns){
           
    //Select 13th Date 

    if (cell.getText().equals(formEntryMap.get(columnKey))) 

= 这将从输入为 8/23/2021 的表单中获取值

{
    cell.findElement(By.linkText(formEntryMap.get(columnKey))).click();
    clickOnButton(driver, AppXPathsConstants.CalenderbuttonXpath);

= 在日历的末尾有一个打勾按钮,单击它将关闭日历并将添加日期为 2021 年 8 月 25 日,16:05:20

日期选择部分不工作,需要输入关于可以做些什么来使它工作,

有人可以就此提供意见吗?可以添加更多信息

我已经解决了这个问题。由于日期字段是一个输入框,我采用了 xpath 并输入了日期.....

标签: javaseleniumselenium-webdriverautomation

解决方案


推荐阅读