简体   繁体   English

如何从日历中选择日期(日期选择器)

[英]How to select date from calendar (datepicker )

I'm new in Selenium . 我是Selenium新手。 I'm using C# language. 我正在使用C#语言。 I would like to select a date from calendar (datepicker), and I must select two different calendars and sendkeys (date). 我想从日历(日期选择器)中选择一个日期,并且必须选择两个不同的日历和sendkey(日期)。

First calendar: today 第一个日历:今天

Second calendar : tomorrow 第二日历:明天

页面的此快照

Scenario1: You have Text Box attached to DatePicker and your TextBox is Enabled to enter details. 方案1:您将文本框附加到DatePicker,并且已启用文本框以输入详细信息。 Then Directly Send the Date to Text Box in Secified format 然后将日期直接以指定格式发送到文本框

 IWebElement txtBxDatePicker = driver.FindElement(By.Id("TextBoxOfDatePicker"));
txtBxDatePicker.SendKeys("dd/mm/yyy"); //Send in Required Format.

Scenario2: You have Text Box attached to DatePicker and your TextBox is Disabled to enter details. 方案2:您有文本框附加到DatePicker,并且您的文本框被禁用以输入详细信息。 Change the Read-Only Attribute of Text box to false using JavaScriptExecuter.And then Use above code. 使用JavaScriptExecuter将“文本的只读属性”框更改为false。然后使用上面的代码。

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

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