implementing Generic object

4 posts, 0 answers
  1. sreekanth n
    sreekanth n avatar
    2 posts
    Member since:
    Jan 2010

    Posted 17 Dec 2013 Link to this post

    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.
  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 20 Dec 2013 Link to this post

    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
  3. sreekanth n
    sreekanth n avatar
    2 posts
    Member since:
    Jan 2010

    Posted 20 Dec 2013 Link to this post

    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


  4. Boyan Boev
    Admin
    Boyan Boev avatar
    1039 posts

    Posted 20 Dec 2013 Link to this post

    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
Back to Top