Example #1
0
        public void Save(TestCaseHtml testCase, bool isPassed)
        {
            var testLog = GetLogs();

            testLog.Add(new TestLog {
                TestCase = testCase, IsPassed = isPassed, Date = DateTime.Now
            });
            File.WriteAllText(_logFile, JsonHelper.Serialize(testLog));
        }
Example #2
0
        public PlayWindow(MainWindow parent, IWebDriver webDriver, TestCaseHtml testCase)
        {
            InitializeComponent();

            _parent    = parent;
            _webDriver = webDriver;
            _testCase  = testCase;

            _testLogService = new TestLogService();
        }
Example #3
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            _selectedTestCase = StoryList.SelectedItem as TestCaseHtml;
            _selectedBrowser  = BrowserList.SelectedItem as Browser;
            if (_selectedBrowser == null || _selectedTestCase == null)
            {
                MessageBox.Show("Select a browser and test case above then click play.");
                return;
            }

            switch (_selectedBrowser.Name)
            {
            case "Chrome":
                if (_webDriver == null || _webDriver.GetType() != typeof(ChromeDriver))
                {
                    if (_webDriver != null)
                    {
                        _webDriver.Quit();
                    }
                    _webDriver = new ChromeDriver();
                }
                break;

            case "Edge":
                if (_webDriver == null || _webDriver.GetType() != typeof(EdgeDriver))
                {
                    if (_webDriver != null)
                    {
                        _webDriver.Quit();
                    }
                    _webDriver = new EdgeDriver();
                }
                break;

            case "Firefox":
                if (_webDriver == null || _webDriver.GetType() != typeof(FirefoxDriver))
                {
                    if (_webDriver != null)
                    {
                        _webDriver.Quit();
                    }
                    _webDriver = new FirefoxDriver();
                }
                break;

            case "Internet Explorer":
                if (_webDriver == null || _webDriver.GetType() != typeof(InternetExplorerDriver))
                {
                    if (_webDriver != null)
                    {
                        _webDriver.Quit();
                    }
                    InternetExplorerOptions internetExplorerOptions = new InternetExplorerOptions
                    {
                        IntroduceInstabilityByIgnoringProtectedModeSettings = true,
                    };
                    _webDriver = new InternetExplorerDriver(internetExplorerOptions);
                }
                break;

            default:
                _webDriver = new FirefoxDriver();
                break;
            }

            var playWindow = new PlayWindow(this, _webDriver, _selectedTestCase);

            playWindow.Play();

            Application.Current.MainWindow = playWindow;
            this.Hide();
            playWindow.Show();
        }