public void Valid(string Tvalue, string sType = null, string Target = null) { //Deal with Command var Itmes = JSupport.ComandParse(ref Tvalue, ref Target, ref sType); //Action foreach (string item in Itmes) { switch (item) { case "@弹出框校验": JValid.ValidAlert(driver, Tvalue); break; case "@文本": element = JElement.GetValidXpath(driver, Tvalue, Target); break; case "@对比": if (!element.Text.Contains(Tvalue)) { throw new Exception(string.Format("✘:文本校验失败,请检查文本:{0}", Tvalue)); } break; default: throw new ArgumentOutOfRangeException(string.Format("✘:sType命令中不存在:{0},请核对", Itmes)); } } }
public void SelectOption(string Tvalue, string Target, string sType) { //Deal with Command var Itmes = JSupport.ComandParse(ref Tvalue, ref Target, ref sType); SelectElement SelectOption = null; //Action foreach (string item in Itmes) { switch (item) { case "@传统下拉框": element = JElement.GetSelectElement(driver, Tvalue, Target); SelectOption = new SelectElement(element); break; case "@文本选择": SelectOption.SelectByText(Tvalue); break; default: throw new ArgumentOutOfRangeException(string.Format("✘:下拉框命令中不存在:{0},请核对", item)); } } }
public void InputText(string Tvalue, string Target, string sType) { //Deal with Command List <string> Itmes = JSupport.ComandParse(ref Tvalue, ref Target, ref sType); //Action foreach (string item in Itmes) { switch (item) { case "@普通文本框": element = JElement.GetInputElement(driver, Tvalue, Target); break; case "@文件文本框": element = JElement.GetFileInputElement(driver, Tvalue, Target); break; case "@清空": JAction.Clear(element); break; case "@搜索": JAction.EnterAction(driver, element); break; case "@输入": JAction.SendKeys(element, Tvalue); break; default: throw new ArgumentOutOfRangeException(string.Format("✘:sType命令中不存在:{0},请核对", item)); } } }
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)); } } }
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)); } } }