简体   繁体   中英

Coded UI Test DateTime issue

I use coded UI test and I have a problem. I want to type a date in edittext, but it gives an error message, where is the problem,thanks.

public void TheDate()
{
    #region Variable Declarations
    HtmlEdit uITxtDateEdit = this.UIEWindowWindow8.UIDemoSiteDocument.UITxtDateEdit;
    #endregion

    uITxtDateEdit.Text = DateTime.Now.AddMonths(4).ToString("dd/MM/yyyy");            
}

Cannot perform 'SetProperty of Text with value "16.08.2013"' on the control.

Additional Details:

TechnologyName: 'Web' ControlType: 'Edit' TagName: 'INPUT' Id: 'ctl00_ctl00_ctl00_wpm1_gwpc1_c1_txtDepartureDate_txtDate' Name: 'ctl00$ctl00$ctl00$wpm1$gwpc1$c1$txtDepartureDate_txtDate'

uITxtDateEdit.Text = DateTime.Now.AddMonths(4).ToString("dd/MM/yyyy");

You are trying to insert date in other format. either use dd/mm/yyyy or modify the format to dd.mm.yyyy. Secondly you have mention MM (Capital) which is used for minutes. Try this hope it resolve your issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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