我需要在日期选择器中获取预选的日期。我面临的问题是,当我单击日历时,尝试进入datepicker表时,它被关闭了。有什么办法可以使日期选择器中显示的当前文本/日期。 以下是HTML代码:
<div _ngcontent-c4="" class="form-group">
<input class="form-control datepicker" id="violationEndDate" placeholder="Date Picker Here" type="text" _ngcontent-c3="">
</div>
答案 0 :(得分:0)
您可以在C#中使用以下命令:-
String currentDate = Driver.FindElement(By.Id("violationEndDate")).Text;
据我所见,id是违规结束日期 您还可以使用xpath或cssSelector
String currentDate = Driver.FindElement(By.XPath("*//input[@id='violationEndDate'
and contains(@class, 'datepicker' )]")).Text;
我没有进行测试,因为我没有完整的HTML DOM代码 希望这会有所帮助