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

implementing Generic object

5 Answers 91 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sreekanth n
Top achievements
Rank 1
sreekanth n asked on 17 Dec 2013, 09:48 AM
I am building helper methods to reuse the code.   I wanted to user Generic object reference in helper methods so that user can specify whether object is of  HtmlInputSubmit or HtmlInputText.

To elaborate my requirement, i would writing below code in helper method

                T _WebElement = _Manager.ActiveBrowser.Find.ById<T>(locator);

While invoking helper method, i would write like

            TelerikElement<HtmlControl> searchCriteria = new TelerikElement<HtmlControl>(wDriver);
            searchCriteria.FindWebElement(LocateBy.Name, "q").SetValue("Telerik Testing Framework");

Error:
There is no boxing conversion or type parameter conversion form T to ArtofTest.WebAii.Controls.Control.

Is there any workaround to implement this logic.

5 Answers, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 20 Dec 2013, 11:40 AM
Hello Sreekanth,

Thank you for contacting us.

Could please elaborate a bit more on your scenario. What exactly do you want to achieve.

Basically the generic item in our framework for html elements is Element and for Silverlight and WPF is FrameworkElements. You can use them to create generic methods then you need to cast them to a concrete type of element. Here is an example:

Element myElement = ActiveBrowser.Find.ById("myID");
HtmlDiv theCasteElement = myElement.As<HtmlDiv>();

Hope this helps.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
sreekanth n
Top achievements
Rank 1
answered on 20 Dec 2013, 12:02 PM
We are building helper methods to minimize number of methods call to identify web elements. It is to migrate from Selenium to Telerik framework.   IN this regard we wanted end user to pass type of control like HTMLControl, HTMLTextBox etc [given in the example] to helper methods.

We could achieve this today and able to make progress.  Since application uses Kendo UI controls, we are using Htmlcontrols instead of element.   Hope our approach is correct. 

Thanks for your response.

regards


0
Boyan Boev
Telerik team
answered on 20 Dec 2013, 01:41 PM
Hi Sreekanth,

Glad to hear that.

If you need any additional help, please do not hesitate to contact us.

Regards,
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Simran
Top achievements
Rank 1
answered on 11 Apr 2019, 03:55 PM

Hello Sreekanth,

I am also trying to build a helper methods to reuse code and migrate to Telerik from Selenium,  but stuck. Can you please elaborate how did you resolve that problem.

Regards

Simran

0
Elena
Telerik team
answered on 16 Apr 2019, 07:54 AM
Hello Simran,

I am not familiar in details what are the challenges you have up in front and what troubles you have faced so far and thus will provide some general guidance on the topic. 

Please, find here an example of a Helper Utility class file, which you can use to store the methods to reuse across the project. Some useful notes how elements are found with the Testing Framework can be read here. How to navigate through the elements in the DOM tree will be also helpful for you. What actions you can send upon the elements are also helpful notes. 

I hope the above will fit your queries. However, if you have any specific queries, please provide more details on what you cannot accomplish and what is the approach you have tried. 

Thank you for your understanding in advance. 

Regards,
Elena Tsvetkova
Progress Telerik
 
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
 
Tags
General Discussions
Asked by
sreekanth n
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
sreekanth n
Top achievements
Rank 1
Simran
Top achievements
Rank 1
Elena
Telerik team
Share this question
or