Code & QA

WebApplication class

The next step in the framework development is the creation of a web application class. The class is a projection of a web application under test. It is located in the Mapping project. It’s assumed that there should be only one instance of the class during a test run session. But actually it is non-static and it is not implemented Singleton design pattern, therefore, you can create a number of application instances and run them all in parallel. You can do experiments with it if you wish. As far as the experiment is out of the scope of the current topic I will count it out here.

So, for testing I use the only one instance of WebApplication and, therefore, there will be the only one instance of IWebDriver interface used during the testing which is instantiated in WebApplication’s constructor.

WebApplication class contains:

• An instance of the Selenium IWebDriver;

• Instances of all pages which real tested application consists of. Every single page instance is a projection of a real web page;

• Auxiliary variables which reflect the application’s status and are utilized inside the class;

• A method for initialization of necessary web page instances;

• A method for quitting the application and closing the browser.

I added new WebApplication class to the Mapping project.

using OpenQA.Selenium;

namespace Mapping

{

    /// <summary>
    /// projection of an application under test
    /// </summary>
    public class WebApplication
    {

        internal IWebDriver Driver {
            get;
            private set;
        }

        public WebApplication(IWebDriver driver)
        {
            this.Driver = driver;
            _isNew = true;
        }
  
        bool _isNew;
        internal static bool IsValid;

        # region Pages
        //this section will be filled up after classes of the application web pages will be added to the framework
        # endregion Pages
        /// <summary>
        /// initializes an instance of specified web page
        /// </summary>
        /// <typeparam name="T">type of web page for initialization</typeparam>
        /// <param name="args"></param>
        public void Open < T > (params object[] args) where T: IWebPage
        {
            _isNew = false;
            //will be filled up after classes of the application web pages will be added to the framework
        }
        /// <summary>
        /// closes the application (browser)
        /// </summary>
        public void Quit()
        {
            Driver.Quit();
            _isNew = true;
        }
    }
}

Global variables                                                          Table Of Content                                                   WebPage Class

Leave a Reply

Your email address will not be published. Required fields are marked *


Notice: Undefined offset: 0 in /home/chyqruxavcln/public_html/learnseleniumtesting.com/wp-content/plugins/cardoza-facebook-like-box/cardoza_facebook_like_box.php on line 924