How to select the Date Picker In Selenium WebDriver

后端 未结 8 1809
再見小時候
再見小時候 2020-12-03 00:02

Currently working on Selenium WebDriver and using Java. I want to select values in date range from the drop down.. I want to k

相关标签:
8条回答
  • 2020-12-03 00:48
    public String datePicker(String object,String data){
        APP_LOGS.debug("selecting date");
        try{
    
            WebElement dateWidget = driver.findElement(By.xpath(OR.getProperty(object)));
    
            List<WebElement> rows = dateWidget.findElements(By.tagName("tr"));  
            List<WebElement> columns = dateWidget.findElements(By.tagName("td"));  
    
            for (WebElement cell: columns){
                if (cell.getText().equals(data)){
                    cell.findElement(By.linkText(data)).click();
                    break; 
                }
            }
        }catch(Exception e){
            return Constants.KEYWORD_FAIL+" -- Not able to select the date"+e.getMessage();
        }
        return Constants.KEYWORD_PASS;
    }
    
    0 讨论(0)
  • try to SendKeys instead of picking the date

    driver.FindElement(yourBy).SendKeys(yourDateTime.ToString("ffffd, dd.MM.yyyy",CultureInfo.CreateSpecificCulture("en-US")));
    

    If it does not work, try to send native 'tab'

    element.SendKeys(OpenQA.Selenium.Keys.Tab);
    
    0 讨论(0)
提交回复
热议问题