public Dictionary <string, MenuAction> GetAction(string accessPath, object driver)
        {
            var dic = new Dictionary <string, MenuAction>();

            if (driver is IWebDriver web)
            {
                dic["Url"] = () =>
                {
                    CaptureAdaptor.AddCode(accessPath + ".Url = \"" + web.Url + "\";");
                };
            }
            else
            {
                dic["Assert"] = () =>
                {
                    AssertSingle(accessPath, driver);
                };

                dic["Assert All"] = () =>
                {
                    foreach (var e in driver.GetType().GetProperties())
                    {
                        var obj = e.GetValue(driver);
                        if (obj == null)
                        {
                            continue;
                        }

                        AssertSingle(accessPath + "." + e.Name, obj);
                    }
                };
            }
            return(dic);
        }
示例#2
0
        static void Assert(string accessPath, FormsMonthCalendar monthCalendar)
        {
            CaptureAdaptor.AddUsing(typeof(DateTime).Namespace);
            var value = monthCalendar.SelectedDay;

            CaptureAdaptor.AddCode($"{accessPath}.SelectedDay.Date.Is(new DateTime({value.Year}, {value.Month}, {value.Day}));");
        }
示例#3
0
        static void Assert(string accessPath, FormsListBox listBox)
        {
            var texts = listBox.GetAllItemText();

            for (int i = 0; i < texts.Length; i++)
            {
                CaptureAdaptor.AddCode($"{accessPath}.GetItemText({i}).Is({ToLiteral(listBox.GetItemText(i))});");
            }
        }
示例#4
0
        static void Assert(string accessPath, FormsCheckedListBox checkedListBox)
        {
            var count = checkedListBox.ItemCount;

            for (int i = 0; i < count; i++)
            {
                var checkState = checkedListBox.GetCheckState(i);
                CaptureAdaptor.AddCode($"{accessPath}.GetCheckState({i}).Is(CheckState.{checkState});");
            }
        }
 void Assert(string accessPath, WPFTreeView treeView)
 {
     if (treeView.SelectedItem.AppVar.IsNull)
     {
         CaptureAdaptor.AddCode($"{accessPath}.SelectedItem.AppVar.IsNull.IsTrue();");
     }
     else
     {
         CaptureAdaptor.AddCode($"{accessPath}.SelectedItem.Text.Is({ToLiteral(treeView.SelectedItem.Text)});");
     }
 }
 void Assert(string accessPath, WPFDatePicker datePicker)
 {
     CaptureAdaptor.AddUsing(typeof(DateTime).Namespace);
     if (datePicker.SelectedDate.HasValue)
     {
         var value = datePicker.SelectedDate.Value;
         CaptureAdaptor.AddCode($"{accessPath}.SelectedDate.Is(new DateTime({value.Year}, {value.Month}, {value.Day}));");
     }
     else
     {
         CaptureAdaptor.AddCode($"{accessPath}.SelectedDate.IsNull();");
     }
 }
        void Assert(string accessPath, WPFDataGrid dataGrid)
        {
            var rowCount = dataGrid.ItemCount;
            var colCount = dataGrid.ColCount;

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    var text = ToLiteral(dataGrid.GetCellText(row, col));
                    CaptureAdaptor.AddCode($"{accessPath}.GetCellText({row}, {col}).Is({text});");
                }
            }
        }
示例#8
0
        static void Assert(string accessPath, FormsListView listView)
        {
            var rowCount = listView.ItemCount;
            var colCount = listView.ColumnCount;

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    var text = ToLiteral(listView.GetListViewItem(row).GetSubItem(col).Text);
                    CaptureAdaptor.AddCode($"{accessPath}.GetListViewItem({row}).GetSubItem({col}).Text.Is({text});");
                }
            }
        }
示例#9
0
        static void Assert(string accessPath, FormsDataGridView dataGridView)
        {
            var rowCount = dataGridView.RowCount;
            var colCount = dataGridView.ColumnCount;

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    var text = ToLiteral(dataGridView.GetCell(col, row).Text);
                    CaptureAdaptor.AddCode($"{accessPath}.GetCell({col}, {row}).Text.Is({text});");
                }
            }
        }
示例#10
0
        static void AssertSingle(string accessPath, object obj)
        {
            if (obj is WPFTextBox textBox)
            {
                CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + textBox.Text + "\");");
            }
            if (obj is WPFComboBox combo)
            {
                CaptureAdaptor.AddCode(accessPath + ".SelectedIndex.Is(" + combo.SelectedIndex + ");");
            }
            if (obj is WPFToggleButton toggle)
            {
                var ret = toggle.IsChecked == null ? "IsNull()" :
                          toggle.IsChecked == true ? "Value.IsTrue()" : "Value.IsFalse()";
                CaptureAdaptor.AddCode(accessPath + ".IsChecked." + ret + ";");
            }
            if (obj is WPFCalendar calender)
            {
                var ret = calender.SelectedDate == null ? "IsNull()" :
                          "Is(new DateTime(" + calender.SelectedDate.Value.Year + ", " + calender.SelectedDate.Value.Month + ", " + calender.SelectedDate.Value.Day + "))";
                CaptureAdaptor.AddCode(accessPath + ".SelectedDate." + ret + ";");
            }
            if (obj is WPFNumericUpDownDriver numericUpDown)
            {
                CaptureAdaptor.AddCode(accessPath + ".Value.Is(" + numericUpDown.Value + ");");
            }
            if (obj is WPFDataGrid grid)
            {
                var rowCount = grid.ItemCount;
                var colCount = grid.ColCount;
                for (int row = 0; row < rowCount; row++)
                {
                    for (int col = 0; col < colCount; col++)
                    {
                        var text = grid.GetCellText(row, col);

                        CaptureAdaptor.AddCode(accessPath +
                                               ".GetCellText(" + row + ", " + col + ").Is(\"" + text + "\");");
                    }
                }
            }
        }
 static void AssertSingle(string accessPath, object obj)
 {
     if (obj is AnchorDriver anchor)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + anchor.Text + "\");");
     }
     if (obj is DateDriver date)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + date.Text + "\");");
     }
     if (obj is DropDownListDriver dropdown)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + dropdown.Text + "\");");
     }
     if (obj is LabelDriver label)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + label.Text + "\");");
     }
     if (obj is RadioButtonDriver radio)
     {
         CaptureAdaptor.AddCode(accessPath + ".Checked.Is(" + radio.Checked + ");");
     }
     if (obj is CheckBoxDriver check)
     {
         CaptureAdaptor.AddCode(accessPath + ".check.Is(" + check.Checked + ");");
     }
     if (obj is TextAreaDriver textArea)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + textArea.Text + "\");");
     }
     if (obj is TextBoxDriver textBox)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + textBox.Text + "\");");
     }
     if (obj is IWebElement element)
     {
         CaptureAdaptor.AddCode(accessPath + ".Text.Is(\"" + element.Text + "\");");
     }
 }
示例#12
0
 static void Assert(string accessPath, DropDownListDriver dropdown)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(dropdown.Text) + ");");
        void Assert(string accessPath, WPFToggleButton toggleButton)
        {
            var value = toggleButton.IsChecked == null ? "null" : toggleButton.IsChecked.Value.ToString().ToLower();

            CaptureAdaptor.AddCode($"{accessPath}.IsChecked.Is({value});");
        }
 void Assert(string accessPath, WPFTextBlock textBlock)
 => CaptureAdaptor.AddCode($"{accessPath}.Text.Is({ToLiteral(textBlock.Text)});");
 void Assert(string accessPath, WPFTabControl tabControl)
 => CaptureAdaptor.AddCode($"{accessPath}.SelectedIndex.Is({tabControl.SelectedIndex});");
 void Assert(string accessPath, WPFSlider slider)
 => CaptureAdaptor.AddCode($"{accessPath}.Value.Is({slider.Value});");
示例#17
0
 static void Assert(string accessPath, CheckBoxDriver check)
 => CaptureAdaptor.AddCode(accessPath + ".Checked.Is(" + check.Checked.ToString().ToLower() + ");");
示例#18
0
 static void Assert(string accessPath, FormsTrackBar trackBar)
 => CaptureAdaptor.AddCode($"{accessPath}.Value.Is({trackBar.Value});");
 void Assert(string accessPath, WPFProgressBar progressBar)
 => CaptureAdaptor.AddCode($"{accessPath}.Value.Is({progressBar.Value});");
 void Assert(string accessPath, WPFListView listView)
 => CaptureAdaptor.AddCode($"{accessPath}.SelectedIndex.Is({listView.SelectedIndex});");
 void Assert(string accessPath, WPFComboBox comboBox)
 => CaptureAdaptor.AddCode($"{accessPath}.SelectedIndex.Is({comboBox.SelectedIndex});");
示例#22
0
 static void Assert(string accessPath, LabelDriver label)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(label.Text) + ");");
示例#23
0
        public Dictionary <string, Action> GetAction(string accessPath, object driver)
        {
            var dic = new Dictionary <string, Action>();

            if (driver is IWebDriver web)
            {
                dic["Url"] = () =>
                {
                    CaptureAdaptor.AddCode(accessPath + ".Url = " + ToLiteral(web.Url) + ";");
                };
                dic["Alert - Accept"] = () =>
                {
                    CaptureAdaptor.AddCode(accessPath + ".WaitForAlert().Accept();");
                    CaptureAdaptor.AddUsing("Selenium.StandardControls");
                };
                dic["Alert - Dismiss"] = () =>
                {
                    CaptureAdaptor.AddCode(accessPath + ".WaitForAlert().Dismiss();");
                    CaptureAdaptor.AddUsing("Selenium.StandardControls");
                };
            }
            else
            {
                if (driver is AnchorDriver anchor)
                {
                    dic["Assert"] = () => Assert(accessPath, anchor);
                }
                else if (driver is DateDriver date)
                {
                    dic["Assert"] = () => Assert(accessPath, date);
                }
                else if (driver is DropDownListDriver dropdown)
                {
                    dic["Assert"] = () => Assert(accessPath, dropdown);
                }
                else if (driver is LabelDriver label)
                {
                    dic["Assert"] = () => Assert(accessPath, label);
                }
                else if (driver is RadioButtonDriver radio)
                {
                    dic["Assert"] = () => Assert(accessPath, radio);
                }
                else if (driver is CheckBoxDriver check)
                {
                    dic["Assert"] = () => Assert(accessPath, check);
                }
                else if (driver is TextAreaDriver textArea)
                {
                    dic["Assert"] = () => Assert(accessPath, textArea);
                }
                else if (driver is TextBoxDriver textBox)
                {
                    dic["Assert"] = () => Assert(accessPath, textBox);
                }
                else if (driver is IWebElement element)
                {
                    dic["Assert"] = () => Assert(accessPath, element);
                }
                else if (IsItemsControl(driver))
                {
                    dic["Assert"] = () => AssertItemsControl(accessPath, driver);
                }
                else
                {
                    dic["Assert All"] = () => AssertAll(accessPath, driver);
                }
            }
            return(dic);
        }
示例#24
0
 static void Assert(string accessPath, IWebElement element)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(element.Text) + ");");
示例#25
0
 static void Assert(string accessPath, TextBoxDriver textBox)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(textBox.Text) + ");");
示例#26
0
 static void Assert(string accessPath, DateDriver date)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(date.Text) + ");");
示例#27
0
 static void Assert(string accessPath, AnchorDriver anchor)
 => CaptureAdaptor.AddCode(accessPath + ".Text.Is(" + ToLiteral(anchor.Text) + ");");
 void Assert(string accessPath, WPFRichTextBox richTextBox)
 => CaptureAdaptor.AddCode($"{accessPath}.Text.Is({ToLiteral(richTextBox.Text)});");
 void Assert(string accessPath, WPFSelector selector)
 => CaptureAdaptor.AddCode($"{accessPath}.SelectedIndex.Is({selector.SelectedIndex});");
示例#30
0
 static void Assert(string accessPath, RadioButtonDriver radio)
 => CaptureAdaptor.AddCode(accessPath + ".Checked.Is(" + radio.Checked.ToString().ToLower() + ");");