如何使用选择在页面对象模型中选择日期



>需要从日期选择器中选择一个日期

WebElement  Month = driver.findElement(By.xpath("/html/body/div[9]/div/div/select[2]"));
//Select select = new Select(Month);
// select.selectByValue("1975");

未选取的仅当月和当年

它是一个选择标签,然后你可以使用Selenium Select类本身而不是使用标准脚本

Example:
Select fruits = new Select(driver.findElement(By.id("fruits")));
fruits.selectByVisibleText("Banana");  // by visible text 
fruits.selectByIndex(1);  // by index
fruits.selectByValue("23-10-2019");  //select by value 

如果要使用标准方式,可以使用如下解决方案:

https://www.guru99.com/handling-date-time-picker-using-selenium.html

最新更新