Recently in the study of selenium, encountered the problem of dealing with date control, try several methods are fruitless, finally found a successful one of the processing way.
The entire calendar is controlled in the div:
<input type= "text" name= "StartDate" id= "id_startdate1" size= "All" maxlength= "onfocus=" Assignvalue (' tr_attr_1 ') ; "onkeydown=" return false; "onkeypress=" return false; " >
I first also based on the internet can be directly found in the feasible solution one by one verification, none of the results. Then he continued to ponder the afternoon, the experiment has a feasible solution:
1. First navigate to the picture of the Calendar control and click
Driver.findelement (By.cssselector ("img[alt=\" View calendar\ "]"). Click ();
2. Select one months via ' < ' (similar to the next one months)
Driver.findelement (By.linktext ("<")). Click ();
3. Select the Month
Select select = New Select (Driver.findelement (By.cssselector ("Select.month"));
Select.selectbyvisibletext ("");//fill in the value of the month that needs to be selected
4. Select the year
Select select = New Select (Driver.findelement (By.cssselector ("select.year"));
Select.selectbyvisibletext ("");//fill in the value of the year that you want to select
5. Select ' Today ' date
Driver.findelement (By.linktext ("Today")). Click ();
6. Select the date of the specific day
Driver.findelement (By.xpath ("//tr[1]/td[1]/div")). click;//by specific column information to the date of the specific day
The way of Selenium learning Calendar control