New to Telerik Test Studio? Download free 30-day trial

How to Use Elements From Repository In A Utility Class

I would like to use elements recorded in the Elements repository in my standalone code class file.


We do not recommend using elements from the repository in a standalone class file. If there is a specific scenario you could not avoid you could refer to the example below. You would need to add references to ArtOfTest.WebAii.Core.dll and ArtOfTest.WebAii.Design.dll and include using statements for these in the code file. The Utility class inherits the BaseWebAiiTest and requires definition for region [Dynamic Pages Reference].

using ArtOfTest.WebAii.Core;
using ArtOfTest.WebAii.Design;

namespace SomeTestProject
    public class Utility : BaseWebAiiTest 
        #region [ Dynamic Pages Reference ]

        private Pages _pages;

        public Pages Pages
                if (_pages == null)
                    _pages = new Pages(Manager.Current);
                return _pages;

        public void DoSomething()
            Pages.Bing.SbFormQSearch.Text = "Cat" ;
Imports ArtOfTest.WebAii.Core
Imports ArtOfTest.WebAii.Design

Namespace SomeTestProject
    Public Class Utility
        Inherits BaseWebAiiTest
        #Region "[ Dynamic Pages Reference ]"

        Private _pages As Pages

        Public ReadOnly Property Pages() As Pages
                If _pages Is Nothing Then
                    _pages = New Pages(Manager.Current)
                End If
                Return _pages
            End Get
        End Property
        #End Region

        Public Sub DoSomething()
            Pages.Bing.SbFormQSearch.Text = "Cat"
        End Sub
    End Class
End Namespace

In a coded step you would need to create an instance of this class in order to use its methods as shown below:

// create an instance of the class
var MyClass = new Utility();

// call a method of this class
// create an instance of the class
Dim [MyClass] = New Utility()

// call a method of this class
In this article