This is a migrated thread and some comments may be shown as answers.

RadDatePicker automation

3 Answers 118 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 23 Oct 2009, 11:34 PM
I'm trying to automate a test of the RadDatePicker using WebAii and nUnit. I want to test the date formatting of the RadDatePicker. The following code works fine:

 

HtmlInputText dateBox = base.myManager.ActiveBrowser.Find.ById<HtmlInputText>"ctl00_ContentPlaceHolder1_DatePicker1_rdpCurrentDate_dateInput_text");  
 
 
 
dateBox.Text = "Oct 11";  
 

At this point in a manual scenario, if the user hits {ENTER} or clicks out of the RadDatePicker control the control's behind-the-scenes functionality formats the date to '10/11/2009'. But I can't figure out how to automate the triggering of this formatting functionality.

The following code clears the RadDatePicker control and opens a new browser:

 

  

 

 

ActiveBrowser.Manager.Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Return); 

 

 

 

Automating a click away from the RadDatePicker control incites an error message saying that there are no active browsers:

 

 

 

ActiveBrowser.Find.ById<HtmlInputText>("ctl00_ContentPlaceHolder1_ctl00_dateInput_text").MouseClick(); 

There are no active browsers. Please make sure you have atleast one browser instance launched for automation using Manager.LauncheNewBrowser().

So, I'm stumped. Can you offer any advice?

Thanks!

David

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 24 Oct 2009, 09:09 PM
Hello David,

I hope this recent thread in the forum can help you achieve your goal with the RadDatePicker control automation.

Please let us know if you have additional questions.

Kind regards,
Konstantin Petkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
David
Top achievements
Rank 1
answered on 28 Oct 2009, 05:54 PM
Thanks, Konstantin. That code works but it doesn't address what I wanted to do. Once I type the text, "Oct 11", into the RadDatePicker I want it to resolve to the default format of "10/11/2009". In order for this to happen a user must manually click out of the RadDatePicker or hit <ENTER>. How can I automate clicking out of the box or hitting <ENTER>?

Thanks,

David
0
David
Top achievements
Rank 1
answered on 28 Oct 2009, 07:29 PM
I got it to work. Here's the final code snippet:

 

 

 

 

 

[Test]  
public void MonthDayFormat()  
{  
    Manager.LaunchNewBrowser(BrowserType.InternetExplorer);  
    Manager.ActiveBrowser.NavigateTo(APP_URL + "DatePicker.aspx");  
 
    RadDateInput dateControl = Manager.ActiveBrowser.Find.ById<RadDateInput>("rdpCurrentDate_dateInput_wrapper");  
 
    dateControl.TypeText("Oct 11");  
    Desktop.KeyBoard.KeyPress(System.Windows.Forms.Keys.Enter, 1);  
              
    string yearString = DateTime.Now.Year.ToString();  
    Assert.AreEqual("10/11/" + yearString, dateControl.TextBoxValue);  

 

 

 

 

 

 Thanks!

David

Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
David
Top achievements
Rank 1
Share this question
or