This is a migrated thread and some comments may be shown as answers.
Coded UI Tests with Kendo Controls
6 Answers 16 Views
This is a migrated thread and some comments may be shown as answers.
Chelsea
Top achievements
Rank 1
Chelsea asked on 11 Dec 2015, 06:23 PM

I tried writing Cided UI Tests with Visual Studio 2015 on this webpage: http://demos.telerik.com/aspnetajax/button/examples/radiosandcheckboxes/defaultcs.aspx

where it is supposed to click the checkbox, but I keep receiving an error as it doesn't recognize the kendo control. How am I able to select it without using the recording options? Here is the error:

Test Name: CodedUITestMethod1
Test FullName: CodedUITestProject_test.CodedUITest1.CodedUITestMethod1
Test Source: C:\Team Projects 2015\Demo\CodedUITestProject_test\CodedUITestProject_test\CodedUITest1.cs : line 28
Test Outcome: Failed
Test Duration: 0:01:46.516549
Result Message: 
Test method CodedUITestProject_test.CodedUITest1.CodedUITestMethod1 threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details:
TechnologyName:  'Web'
ControlType:  'CheckBox'
TagName:  'INPUT'
Id:  'RadButton6'
 Failed to find any control that matched the value RadButton6 for the search property Id. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

 

Here is my code:

public void CodedUITestMethod1()
{
Playback.PlaybackSettings.SearchInMinimizedWindows = false;

string Home = "http://demos.telerik.com/aspnet-ajax/button/examples/radiosandcheckboxes/defaultcs.aspx";

BrowserWindow b = BrowserWindow.Launch(Home);
Playback.PlaybackSettings.DelayBetweenActions = 100000;
b.resizedWindow(1920, 1080); //function to make the window full screen
            
HtmlCheckBox cbBox = new HtmlCheckBox(b);

//I had used the ID from the Developer Options under F12 initially then changed it to RadButton6 but it doesn't work
cbBox.SearchProperties.Add(HtmlCheckBox.PropertyNames.Id, "RadButton6");

Mouse.Click(cbBox);

}

 

6 Answers, 1 is accepted

Sort by
0
Joana
Telerik team
answered on 15 Dec 2015, 03:20 PM
Hi Chelsea,

RadButton is rendered as a span element and it cannot be recognized as HtmlCheckBox. Give a try the following code:

var radButton = new HtmlSpan(b);
radButton.SearchProperties.Add(HtmlSpan.PropertyNames.Id, "ctl00_ContentPlaceholder1_RadButton16");
Mouse.Click(radButton);

I hope this is what you're looking for.

Regards,
Joana
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Chelsea
Top achievements
Rank 1
answered on 15 Dec 2015, 03:23 PM

Hi Joana,

What is there is no ID for the element? How would you go about clicking it?

 

0
Chelsea
Top achievements
Rank 1
answered on 15 Dec 2015, 05:00 PM

Hi again,

I have another question regarding a hyperlink. As it is in a Kendo grid, when

I run the CodedUI test, it fails because the element can't be found:

var cbBox = new HtmlHyperlink(b);
cbBox.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id, "btnAdd");
Mouse.Click(cbBox);

 How do I make the test pass?

 

0
Joana
Telerik team
answered on 16 Dec 2015, 12:41 PM
Hello,

Regarding the first question if there is no ID for the element: you could use any of the the SearchProperties that will match the exact element. You could see more examples here.

Most likely, it doesn't matter if the hyperlink is placed in grid or not.  You should be able to successfully locate it if the id is correct. Have you inspected it in the Developer Toolbar? If you send me a live url or some example, I would be able to give you more guidelines how to write the test.

Regards,
Joana
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Chelsea
Top achievements
Rank 1
answered on 16 Dec 2015, 02:39 PM

I have attached screenshots of the Dev Toolbar and the webpage itself. It is a hyperlink inside a kendo grid. As you can see, the Id is btnAdd. The error I receive is that the element with that Id is not found so I assumed it was because it is nested in the kendo grid. The code I have been using is:

 

BrowserWindow b = BrowserWindow.Launch(Home);
var cbBox = new HtmlHyperlink(b);
cbBox.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id, "btnAdd");
Mouse.Click(cbBox);

 

0
Joana
Telerik team
answered on 21 Dec 2015, 08:43 AM
Hi Chelsea,

Locate the parent HTML element of the anchor and search for a child element that has id btnAdd. Try using HtmlCustom instead of HtmlHyperlink. Please note, that getting reference to a HTML elements is not related to the Telerik controls, but general knowledge in writing tests in code.

Regards,
Joana
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Asked by
Chelsea
Top achievements
Rank 1
Answers by
Joana
Telerik team
Chelsea
Top achievements
Rank 1
Share this question
or