繁体   English   中英

如何从日期选择器离子硒网驱动器中选择日期?

[英]How to select date from date picker ion selenium web driver?

在Selenium Web驱动程序中从日期选择器中选择日期的代码是什么? 我们在Java Selenium Web驱动程序编码上尝试了很多

![用于Web驱动程序的硒编码] [ http://i.stack.imgur.com/15gdR.png]

查找以下附件的屏幕截图

尝试这个

单击加入日期字段,然后单击所需的日期,例如

driver.findElement(By.<Joining Date field>).click();
driver.findElement(By.linkText(<Date>)).click();

例如:

driver.findElement(By.id("calendarSelect")).click();
driver.findElement(By.linkText("6")).click();

使用Absolute xpath,只需使用firebug标识该日期选择器的日期,然后右键单击以获取xpath,然后使用该xpath选择该元素

试试这个,它永远不会失败

`尝试{

    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();
}`

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM