Beispiel #1
0
        /// <summary>
        /// loads actions from file
        /// </summary>
        /// <param name="filename">filename to load from</param>
        public void LoadActionsFromFile(string filename)
        {
            SerializeActionHelper.DeserializeActionListFromFile(filename, out _actionList, out _browsers);
            int index = 0;

            foreach (ActionBase action in _actionList)
            {
                OnActionAdded(action, index++);
            }
        }
Beispiel #2
0
        private string WriteSelectActionToFile()
        {
            const string filename = @"C:\Work\TestRecorder3\tests\output_select.xml";
            var          action   = new ActionSelect(new BrowserWindow("window"), GetInputElement("select"));

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                action
            }, filename);
            return(filename);
        }
Beispiel #3
0
        private string WriteSleepActionToFile()
        {
            const string filename = @"C:\Work\TestRecorder3\tests\output_sleep.xml";
            var          action   = new ActionSleep(null)
            {
                Miliseconds = 5000
            };

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                action
            }, filename);
            return(filename);
        }
Beispiel #4
0
        private string WriteNavigateActionToFile()
        {
            const string filename = @"C:\Work\TestRecorder3\tests\output_navigate.xml";
            var          action   = new ActionNavigate(new BrowserWindow("window"))
            {
                Url = "http://www.google.com"
            };

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                action
            }, filename);
            return(filename);
        }
Beispiel #5
0
        private string WriteAlertHandlerToFile()
        {
            const string filename    = @"C:\Work\TestRecorder3\tests\output_alerthandler.xml";
            var          clickAction = new ActionClick(new BrowserWindow("window"), GetInputElement("input"));
            var          alertAction = new ActionAlertHandler(new BrowserWindow("window"))
            {
                WrapAction = clickAction
            };

            SerializeActionHelper.SerializeActionListToFile(new List <ActionBase> {
                clickAction, alertAction
            }, filename);
            return(filename);
        }
Beispiel #6
0
        public void DeserializeAlertHandler()
        {
            string filename = WriteAlertHandlerToFile();

            Assert.IsTrue(File.Exists(filename), "Output File does not exist");
            List <ActionBase> actionList;
            Dictionary <string, BrowserWindow> windowList;

            SerializeActionHelper.DeserializeActionListFromFile(filename, out actionList, out windowList);
            Assert.AreEqual(2, actionList.Count, "Action list is not 2");
            ActionBase firstClick = actionList.Find(a => a.GetType() == typeof(ActionClick));
            ActionBase firstAlert = actionList.Find(a => a.GetType() == typeof(ActionAlertHandler));

            Assert.AreEqual(firstClick, firstAlert.WrapAction, "action not connected");
        }
Beispiel #7
0
// ReSharper disable UnusedParameter.Local
        private ActionBase CheckSingleBaseDeserial(string filename, Type intendedType, bool hasWindow = true)
// ReSharper restore UnusedParameter.Local
        {
            Assert.IsTrue(File.Exists(filename), "Output File does not exist");
            List <ActionBase> actionList;
            Dictionary <string, BrowserWindow> windowList;

            SerializeActionHelper.DeserializeActionListFromFile(filename, out actionList, out windowList);
            Assert.AreEqual(1, actionList.Count, "Action list is not 1");

            Assert.IsTrue(intendedType == actionList[0].GetType(), "Action is not click");
            if (hasWindow)
            {
                Assert.IsNotNull(actionList[0].ActionWindow, "window is null");
                Assert.AreEqual("window", actionList[0].ActionWindow.InternalName, "internal window name not 'window'");
            }
            return(actionList[0]);
        }
Beispiel #8
0
 /// <summary>
 /// saves actions to file
 /// </summary>
 /// <param name="filename">filename to save</param>
 public void SaveActionsToFile(string filename)
 {
     SerializeActionHelper.SerializeActionListToFile(_actionList, filename);
 }