Example #1
0
        /* ITestApp CreateTestApp()
         * return expected app interface.
         * This interface is used to control the desktop application.
         */
        public static ITestApp CreateTestApp()
        {
            //if it is not desktop application, return null.
            if (_appType != 2)
            {
                return(null);
            }

            if (String.IsNullOrEmpty(_testActionDLL))
            {
                throw new CannotLoadDllException("Test app dll can not be null.");
            }
            try
            {
                //load the dll, convert to expcted interface.
                _app = (ITestApp)LoadDll(_testAppDLL, _testAppClassName);
            }
            catch (Exception ex)
            {
                throw new CannotLoadDllException("Can not create instance of test app: " + ex.ToString());
            }

            if (_app == null)
            {
                throw new CannotLoadDllException("Can not create instance of test app.");
            }

            return(_app);
        }
Example #2
0
        internal static void Run(
            ITestApp app,
            [CallerMemberName] string callerName    = "[unknown test]",
            [CallerFilePath] string sourceFilePath  = "[unknown file]",
            [CallerLineNumber] int sourceLineNumber = 0)
        {
            var fileHint = $"{sourceFilePath}:{sourceLineNumber}";

            app.Run($"{callerName} ({sourceFilePath}:{sourceLineNumber})");

            Inconclusive();
        }
Example #3
0
        /* void LoadPlugin()
         * Get the dll we need.
         * use reflecting to load dll at runtime.
         */
        private void LoadPlugin()
        {
            _objPool = TestFactory.CreateTestObjectPool();

            if (TestFactory.AppType == TestAppType.Desktop)
            {
                _testApp = TestFactory.CreateTestApp();
                _objPool.SetTestWindow(_testApp.CurrentWindow);
            }
            else if (TestFactory.AppType == TestAppType.Web)
            {
                _testBrowser = TestFactory.CreateTestBrowser();
                _objPool.SetTestPage(_testBrowser.CurrentPage);
            }
            else
            {
                throw new CannotInitCoreEngineException("Unknow application type.");
            }
        }
Example #4
0
        /* void PerformGo(TestStep step)
         * Perform normal actions.
         * If the first column in EXCEL driver file is "GO", we will call this method.
         */
        private void PerformGo(TestStep step)
        {
            string item = step._testControl;

            if (item.ToUpper() == "BROWSER")
            {
                if (_testBrowser == null)
                {
                    _testBrowser = (TestInternetExplorer)_objEngine.GetTestBrowser();
                }

                string action = step._testAction.ToUpper();
                if (action == "START")
                {
                    _testBrowser.Start();
                    string url = step._testData;
                    if (!String.IsNullOrEmpty(url) && (url.ToUpper().StartsWith("HTTP://")) || url.ToUpper().StartsWith("HTTPS://"))
                    {

                        _testBrowser.Load(url, false);
                    }
                }
                else if (action == "LOAD")
                {
                    _testBrowser.Load(step._testData, false);
                }
                else if (action == "FIND")
                {
                    _testBrowser.Find(step._testData);
                }
                else if (action == "WAIT")
                {
                    string data = step._testData.ToUpper().Replace(" ", "");

                    int seconds;
                    if (int.TryParse(data, out seconds))
                    {
                        _testBrowser.Wait(seconds);
                    }
                    else
                    {
                        if (data == "NEWPAGE")
                        {
                            _testBrowser.WaitForPage();
                        }
                        else
                        {
                            throw new CannotPerformActionException("Error: Bad data for Wait action: " + data);
                        }
                    }
                }
                else if (action == "MAXSIZE")
                {
                    _testBrowser.Max();
                }
                else if (action == "CLOSE")
                {
                    _testBrowser.Close();
                }
                else if (action == "REFRESH")
                {
                    _testBrowser.Refresh();
                }
                else if (action == "FORWARD")
                {
                    _testBrowser.Forward();
                }
                else if (action == "BACK")
                {
                    _testBrowser.Back();
                }
                else
                {
                    throw new CannotPerformActionException("Unsupported action: " + step._testAction);
                }

                //sleep 1 seconds after browser action, make it looks like human actions
                Thread.Sleep(1000 * 1);

            }
            else if (item.ToUpper() == "APP")
            {
                if (_testApp == null)
                {
                    _testApp = (ITestApp)_objEngine.GetTestApp();
                }
            }
            else
            {
                TestObject obj = _objEngine.GetTestObject(step);

                _testBrowser.Active();

                if (this._isHighlight)
                {
                    ((IVisible)obj).HighLight();
                }

                _actEngine.PerformAction(obj, step._testAction, step._testData);

                //sleep for 1 second, make it looks like human actions
                Thread.Sleep(1000 * 1);
            }

            this._logEngine.WriteLog();
        }
Example #5
0
        /* ITestApp CreateTestApp()
         * return expected app interface.
         * This interface is used to control the desktop application.
         */
        public static ITestApp CreateTestApp()
        {
            //if it is not desktop application, return null.
            if (_appType != 2)
            {
                return null;
            }

            if (String.IsNullOrEmpty(_testActionDLL))
            {
                throw new CannotLoadDllException("Test app dll can not be null.");
            }
            try
            {
                //load the dll, convert to expcted interface.
                _app = (ITestApp)LoadDll(_testAppDLL, _testAppClassName);
            }
            catch (Exception ex)
            {
                throw new CannotLoadDllException("Can not create instance of test app: " + ex.ToString());
            }

            if (_app == null)
            {
                throw new CannotLoadDllException("Can not create instance of test app.");
            }

            return _app;
        }
Example #6
0
 public TestController(ITestApp app)
 {
     _app = app;
 }
Example #7
0
        /* void PerformGo(TestStep step)
         * Perform normal actions.
         * If the first column in EXCEL driver file is "GO", we will call this method.
         */
        private void PerformGo(TestStep step)
        {
            string item = step._testControl;

            if (item.ToUpper() == "BROWSER")
            {
                if (_testBrowser == null)
                {
                    _testBrowser = (TestInternetExplorer)_objEngine.GetTestBrowser();
                }

                string action = step._testAction.ToUpper();
                if (action == "START")
                {
                    _testBrowser.Start();
                    string url = step._testData;
                    if (!String.IsNullOrEmpty(url) && (url.ToUpper().StartsWith("HTTP://")) || url.ToUpper().StartsWith("HTTPS://"))
                    {
                        _testBrowser.Load(url, false);
                    }
                }
                else if (action == "LOAD")
                {
                    _testBrowser.Load(step._testData, false);
                }
                else if (action == "FIND")
                {
                    _testBrowser.Find(step._testData);
                }
                else if (action == "WAIT")
                {
                    string data = step._testData.ToUpper().Replace(" ", "");

                    int seconds;
                    if (int.TryParse(data, out seconds))
                    {
                        _testBrowser.Wait(seconds);
                    }
                    else
                    {
                        if (data == "NEWPAGE")
                        {
                            _testBrowser.WaitForPage();
                        }
                        else
                        {
                            throw new CannotPerformActionException("Error: Bad data for Wait action: " + data);
                        }
                    }
                }
                else if (action == "MAXSIZE")
                {
                    _testBrowser.Max();
                }
                else if (action == "CLOSE")
                {
                    _testBrowser.Close();
                }
                else if (action == "REFRESH")
                {
                    _testBrowser.Refresh();
                }
                else if (action == "FORWARD")
                {
                    _testBrowser.Forward();
                }
                else if (action == "BACK")
                {
                    _testBrowser.Back();
                }
                else
                {
                    throw new CannotPerformActionException("Unsupported action: " + step._testAction);
                }

                //sleep 1 seconds after browser action, make it looks like human actions
                Thread.Sleep(1000 * 1);
            }
            else if (item.ToUpper() == "APP")
            {
                if (_testApp == null)
                {
                    _testApp = (ITestApp)_objEngine.GetTestApp();
                }
            }
            else
            {
                TestObject obj = _objEngine.GetTestObject(step);

                _testBrowser.Active();

                if (this._isHighlight)
                {
                    ((IVisible)obj).HighLight();
                }

                _actEngine.PerformAction(obj, step._testAction, step._testData);

                //sleep for 1 second, make it looks like human actions
                Thread.Sleep(1000 * 1);
            }

            this._logEngine.WriteLog();
        }