Exemple #1
0
        protected void SwitchToSelectedAction()
        {
            if (_currentAction != null)
            {
                var currentUserControl = _currentAction.GetForm();
                _currentAction.SaveState();

                panelAction.Controls.Remove(currentUserControl);
            }

            ///////////////////////////////////////////////////////////////////////////////

            var newAction = (Action)lbSelectedActions.SelectedItem;

            if (newAction != null)
            {
                var newControl = newAction.GetForm();
                newControl.Dock = DockStyle.Fill;

                panelAction.Controls.Add(newControl);

                newAction.RestoreState();

                newControl.Focus();
            }

            ///////////////////////////////////////////////////////////////////////////////

            _currentAction = newAction;

            ///////////////////////////////////////////////////////////////////////////////

            UpdateActionTitleLabel();
        }
Exemple #2
0
        public void RemoveAllActions()
        {
            lbSelectedActions.Items.Clear();

            if (_currentAction != null)
            {
                panelAction.Controls.Remove(_currentAction.GetForm());
                _currentAction = null;
            }
        }
Exemple #3
0
 private void btnStop_Click(object sender, EventArgs e)
 {
     try
     {
         Action.StopActions();
         backgroundWorker1.CancelAsync();
     }
     catch (Exception ex)
     {
         HandleException(ex);
     }
 }
Exemple #4
0
        protected void RemoveSelectedAction()
        {
            if (lbSelectedActions.SelectedIndex != -1)
            {
                lbSelectedActions.Items.RemoveAt(lbSelectedActions.SelectedIndex);
            }

            if (_currentAction != null)
            {
                panelAction.Controls.Remove(_currentAction.GetForm());
                _currentAction = null;
            }

            if (lbSelectedActions.Items.Count > 0)
            {
                lbSelectedActions.SelectedIndex = 0;
            }
        }
Exemple #5
0
        protected void RunSelenium_(List <Action> actionsList)
        {
            SetLogText("");
            Stopwatch sw          = new Stopwatch();
            Stopwatch sw_internal = new Stopwatch();

            Action.StartActions();

            if (txtRootURL.Text == "")
            {
                MessageBox.Show("Please provide root url!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            IWebDriver browser = null;

            try
            {
                browser = new FirefoxDriver();
                Thread.Sleep(5 * 1000);
                {
                    EnablePaneAction(false);

                    for (int i = 0; i < txtRunTimes.Value; i++)
                    {
                        if (backgroundWorker1.CancellationPending)
                        {
                            break;
                        }

                        Log.WriteLog(">> Started " + (i + 1).ToString() + " iteration.", Color.Blue);
                        int actionIndex = 0;

                        foreach (var action in actionsList)
                        {
                            if (backgroundWorker1.CancellationPending)
                            {
                                break;
                            }

                            action.RestoreState();

                            //Append new line
                            Log.WriteLog("", Color.White);

                            SetPaneAction(actionIndex++);

                            if (GlobalSettings.Instance.SaveScreenShots)
                            {
                                string before_img_name = LogDir + "\\" + "TestScreen_.jpg".AppendTimeStamp();
                                browser.CaptureWebPageToFile(before_img_name);
                                Log.WriteLog("Before Image Name: " + before_img_name, Color.Blue);
                            }

                            Action theAction = (Action)action;
                            sw_internal.Restart();
                            Action.Result result = theAction.Run(browser, sw, txtRootURL.Text);
                            sw_internal.Stop();

                            if (GlobalSettings.Instance.SaveScreenShots)
                            {
                                string after_img_name = LogDir + "\\" + "TestScreen_.jpg".AppendTimeStamp();
                                browser.CaptureWebPageToFile(after_img_name);
                                Log.WriteLog("After Image Name: " + after_img_name, Color.Blue);
                            }

                            Log.WriteLog("### Time Elapsed:" + sw_internal.Elapsed.ToString(), Color.Green);

                            if (result == Action.Result.StopAndCloseBrowser)
                            {
                                CloseBrowserIfNeeded(browser);
                                break;
                            }
                            else if (result == Action.Result.Stop)
                            {
                                break;
                            }
                            //Append new line
                            Log.WriteLog("", Color.White);

                            System.Threading.Thread.Sleep(1500);
                        }
                        //Append new line
                        Log.WriteLog("", Color.White);
                        //New iteration
                        Log.WriteLog("@@@@@ Finished " + (i + 1).ToString() + " iteration.", Color.Blue);
                        //Append new line
                        Log.WriteLog("", Color.White);

                        foreach (var action in actionsList)
                        {
                            action.OnTestEnd();
                        }
                    }
                    Log.WriteLog("Finished running actions.", Color.Blue);
                    if (!String.IsNullOrEmpty(this.TestFileName))
                    {
                        Log.Dump(this.TestFileName);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.WriteLog(ex.Message, Color.Red);
            }
            finally
            {
                if (browser != null)
                {
                    CloseBrowserIfNeeded(browser, true);
                }
            }

            EnablePaneAction(true);

            ShowNotification(false);
        }
Exemple #6
0
 public void AddActionToEndOfList(Action action)
 {
     lbSelectedActions.Items.Add(action);
 }