The way of Selenium learning Calendar control

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.