Ejemplo n.º 1
0
        public void ButtonClick(string Tvalue, string sType, string Target = null)
        {
            //Deal with Command
            List <string> Itmes = JSupport.ComandParse(ref Tvalue, ref Target, ref sType);

            //Action
            foreach (string item in Itmes)
            {
                switch (item)
                {
                case "@单击":
                    JAction.Click(element);
                    break;

                case "@JS单击":
                    JAction.ClickJS(driver, element);
                    break;

                case "@右击":
                    JAction.RightClick(driver, element);
                    break;

                case "@双击":
                    JAction.DoubleClick(driver, element);
                    break;

                case "@普通按钮":
                    element = JElement.GetBtnElement(driver, Tvalue, Target);
                    break;

                case "@勾选按钮":
                    element = JElement.GetRadioElement(driver, Tvalue, Target);
                    break;

                case "@树节点按钮":
                    element = JElement.GetTreeNodeElement(driver, Tvalue, Target);
                    break;

                case "@图标按钮":
                    element = JElement.GetIConElement(driver, Tvalue, Target);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(string.Format("✘:sType命令中不存在:{0},请核对", Itmes));
                }
            }
        }
Ejemplo n.º 2
0
        private void btnExcute_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(ComandCollection.Text))
            {
                MessageBox.Show("请先选择命令");
            }
            else
            {
                try
                {
                    int index = ResultDateView.CurrentRow.Index;
                    element = elements[index];
                }
                catch
                {
                    MessageBox.Show(string.Format("请先选择元素,再进行操作"));
                }

                string action = ComandCollection.Text;
                try
                {
                    ClearXpathBorder();
                    switch (action)
                    {
                    case "单击":
                        JAction.Click(element);
                        break;

                    case "JS单击":
                        JAction.ClickJS(driver, element);
                        break;

                    case "Action单击":
                        JAction.ClickAction(driver, element);
                        break;

                    case "双击":
                        JAction.DoubleClick(driver, element);
                        break;

                    case "右击":
                        JAction.RightClick(driver, element);
                        break;

                    case "输入":
                        JAction.SendKeys(element, TvalueTxtBox.Text);
                        break;

                    case "清空":
                        JAction.Clear(element);
                        break;

                    case "下拉-文本选择":
                        SelectElement SelectOption = new SelectElement(element);
                        SelectOption.SelectByText(TvalueTxtBox.Text);
                        break;

                    case "切换IFrame":
                        JSupport.SwitchIFrame(driver, IFrameCollection.Text);
                        break;

                    default:
                        break;
                    }
                    MessageBox.Show(string.Format("{0}-命令操作成功", action));
                }
                catch
                {
                    MessageBox.Show(string.Format("{0}-命令操作失败", action));
                }
            }
        }