How to Use Predefined Elements in a Utility Class

I would like to use elements previously defined in the Elements repository in my stand alone class file.


In general it is not recommended to work with predefined elements in a standalone class file. If there is a specific scenario that can not be avoided at certain development stage of the project the following example could shade some light on such approach. References to ArtOfTest.WebAii.Core and ArtOfTest.WebAii.Design has to be set. The Utility class has to inherit from BaseWebAiiTest and to has a 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 test script coded step an instance of this class has to be created in order to call its methods as shown below:

// create an instance of the class
var MyClass = new Utility();
// call a method of this class

Dim [MyClass] = New Utility()