Java 如何从日期选择器和web驱动程序中选择日期?
selenium web驱动程序中从日期选择器选择日期的代码是什么? 我们在java selenium web驱动程序编码方面做了很多尝试 !![Web驱动程序的Selenium编码] [ 找到下面附加的屏幕截图试试这个 单击加入日期字段,然后单击所需日期,如Java 如何从日期选择器和web驱动程序中选择日期?,java,testing,selenium,automation,webdriver,Java,Testing,Selenium,Automation,Webdriver,selenium web驱动程序中从日期选择器选择日期的代码是什么? 我们在java selenium web驱动程序编码方面做了很多尝试 !![Web驱动程序的Selenium编码] [ 找到下面附加的屏幕截图试试这个 单击加入日期字段,然后单击所需日期,如 driver.findElement(By.<Joining Date field>).click(); driver.findElement(By.linkText(<Date>)).click(); 使用绝对
driver.findElement(By.<Joining Date field>).click();
driver.findElement(By.linkText(<Date>)).click();
使用绝对xpath,只需使用firebug标识日期选择器的日期,右键单击获取xpath,并使用该xpath选择该元素 `试一试{
我们可能需要查看页面来提供帮助,这与移动设备上的日期纠察不同,网站上的日期纠察是自定义的,没有标准来选择。使用绝对自动生成的xpath没有任何优势,并且使代码变得脆弱。在这种情况下,这是最简单但不正确的解决方案。上面的代码不适合我…我在这里检查元素中没有这样的链接文本。你能告诉我们HTML显示了什么,或者给我们一个日历的链接吗
driver.findElement(By.id("calendarSelect")).click();
driver.findElement(By.linkText("6")).click();
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();
}`