public void MotoCreateSiteRenewal(string policyNumber, string renewalPremium, string insurer = "") { HtmlHyperlink uICreateaMotorTestReneHyperlink = map.UIInsurEcomSystemMaintWindow.UILeftbarFrame.UIInsurEcomLeftbarDocument.UIDivRenewalsPane.UICreateaMotorTestReneHyperlink; HtmlComboBox uiInsurerIdComboBox = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UIInsurerIDComboBox; HtmlEdit uITxtPolicyNumberEdit = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPolicyNumberEdit; HtmlEdit uITxtAutoLapseDateEdit1 = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtAutoLapseDateEdit1; HtmlInputButton uICreateRecordButton = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UICreateRecordButton; HtmlEdit uITxtPremiumEdit = UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPremiumEdit; BrowserWindow uIInsurEcomSystemMaintWindow = map.UIInsurEcomSystemMaintWindow; HtmlEdit uITxtRenewalDateEdit = map.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtRenewalDateEdit; Mouse.Click(uICreateaMotorTestReneHyperlink, new Point(50, 22)); uiInsurerIdComboBox.SelectedItem = insurer == "" ? this.map.MotoCreateSiteRenewalParams.UIInsurerIDComboBoxSelectedItem : insurer; uITxtPolicyNumberEdit.Text = policyNumber; uITxtPremiumEdit.Text = renewalPremium; uITxtAutoLapseDateEdit1.Text = uITxtRenewalDateEdit.GetProperty("Text").ToString(); Mouse.Click(uICreateRecordButton); uIInsurEcomSystemMaintWindow.PerformDialogAction(BrowserDialogAction.Ok); }
public void ClickDropDownList(UITestControl parent, string value) { var button = new HtmlComboBox(parent); button.SearchProperties.Add(HtmlComboBox.PropertyNames.Id, value); Mouse.Click(button); }
protected void grvList_RowUpdating(object sender, GridViewUpdateEventArgs e) { HtmlComboBox hcbUNIT = (HtmlComboBox)grvList.Rows[e.RowIndex].FindControl("hcbUNIT"); TextBox txtXH = (TextBox)grvList.Rows[e.RowIndex].FindControl("txtXH"); int temp; if (!int.TryParse(txtXH.Text, out temp)) { detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "NumericalValeError").ToString();; return; } TextBox txtCONTENT = (TextBox)grvList.Rows[e.RowIndex].FindControl("txtCONTENT"); FieldPara[] fields = new FieldPara[3] { new FieldPara("UNIT", FieldType.String, hcbUNIT.SelectedText), new FieldPara("CONTENT", FieldType.String, txtCONTENT.Text), new FieldPara("XH", FieldType.Int, txtXH.Text) }; WherePara[] wheres = new WherePara[1] { new WherePara("TID", FieldType.Int, grvList.DataKeys[e.RowIndex].Value.ToString(), "=", "and") }; _sql = DBOpt.dbHelper.GetUpdateSql("T_DD_TYPICAL_OPT_BODY", fields, wheres); if (DBOpt.dbHelper.ExecuteSql(_sql) > 0) { grvList.EditIndex = -1; initGridView(); detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "SaveSuccessMessage").ToString(); } else { detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "SaveFailMessage").ToString(); return; } }
protected void grvList_RowEditing(object sender, GridViewEditEventArgs e) { grvList.EditIndex = e.NewEditIndex; grvList.EditRowStyle.BackColor = System.Drawing.Color.FromName("#F7CE90"); initGridView(); _sql = "select * from T_DD_TYPICAL_OPT_BODY where TID=" + grvList.DataKeys[e.NewEditIndex].Value; DataTable _dt = DBOpt.dbHelper.GetDataTable(_sql); HtmlComboBox hcb = (HtmlComboBox)grvList.Rows[e.NewEditIndex].FindControl("hcbUNIT"); FillDropDownList.FillHtmlCombxByTable(ref hcb, "DMIS_SYS_STATION", "NAME", "TID", "ORDER_ID"); if (_dt.Rows[0]["UNIT"] != Convert.DBNull) { hcb.Text = _dt.Rows[0]["UNIT"].ToString(); } if (grvList.Rows[e.NewEditIndex].FindControl("txtXH") != null) { TextBox txt = (TextBox)grvList.Rows[e.NewEditIndex].FindControl("txtXH"); if (_dt.Rows[0]["XH"] != Convert.DBNull) { txt.Text = _dt.Rows[0]["XH"].ToString(); } } if (grvList.Rows[e.NewEditIndex].FindControl("txtCONTENT") != null) { TextBox txt = (TextBox)grvList.Rows[e.NewEditIndex].FindControl("txtCONTENT"); if (_dt.Rows[0]["CONTENT"] != Convert.DBNull) { txt.Text = _dt.Rows[0]["CONTENT"].ToString(); } } }
public void SelectItem_ByIndexOnHtmlComboBox_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); comboBox.SelectIndex(1); //Assert Assert.AreEqual("Football", comboBox.SelectedItem); browserWindow.Close(); } }
/// <summary> /// Action_RemoveTheRequiredDataFieldsFromEmployeeDetails - Use 'Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams' to pass parameters into this method. /// </summary> public void Action_RemoveTheRequiredDataFieldsFromEmployeeDetails() { #region Variable Declarations HtmlEdit uICtl00ContentPlaceholEdit = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit; HtmlEdit uICtl00ContentPlaceholEdit1 = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit1; HtmlComboBox uICtl00ContentPlaceholComboBox = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholComboBox; HtmlEdit uICtl00ContentPlaceholEdit2 = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit2; HtmlEdit uICtl00ContentPlaceholEdit3 = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit3; HtmlEdit uICtl00ContentPlaceholEdit4 = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit4; HtmlEdit uICtl00ContentPlaceholEdit5 = this.UIEmployeeDetailsPageWWindow.UIEmployeeDetailsPageDocument.UICtl00ContentPlaceholEdit5; #endregion // Type '' in 'ctl00$ContentPlaceholder1$formViewEmployee$txtFirs...' text box uICtl00ContentPlaceholEdit.Text = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholEditText; // Type '' in 'ctl00$ContentPlaceholder1$formViewEmployee$txtLast...' text box uICtl00ContentPlaceholEdit1.Text = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholEdit1Text; // Select 'None' in 'ctl00$ContentPlaceholder1$formViewEmployee$ddlCoun...' combo box uICtl00ContentPlaceholComboBox.SelectedItem = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholComboBoxSelectedItem; // Type '' in 'ctl00$ContentPlaceholder1$formViewEmployee$txtHire...' text box uICtl00ContentPlaceholEdit2.Text = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholEdit2Text; // Type '' in 'ctl00$ContentPlaceholder1$formViewEmployee$txtAddr...' text box uICtl00ContentPlaceholEdit3.Text = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholEdit3Text; // Type '' in 'ctl00$ContentPlaceholder1$formViewEmployee$txtHome...' text box uICtl00ContentPlaceholEdit4.Text = this.Action_RemoveTheRequiredDataFieldsFromEmployeeDetailsParams.UICtl00ContentPlaceholEdit4Text; // Click 'ctl00$ContentPlaceholder1$formViewEmployee$txtExte...' text box Mouse.Click(uICtl00ContentPlaceholEdit5, new Point(121, 19)); }
protected void grv_RowEditing(object sender, GridViewEditEventArgs e) { if (sender == null) { return; } GridView grv = (GridView)sender; grv.EditIndex = e.NewEditIndex; grv.EditRowStyle.BackColor = System.Drawing.Color.FromName("#F7CE90"); GridViewBind(); int tableID = Convert.ToInt16(Session["MainTableId"]); HtmlComboBox hcb厂站 = (HtmlComboBox)grv.Rows[e.NewEditIndex].FindControl("hcb厂站"); //HtmlComboBox hcb联系人 = (HtmlComboBox)grv.Rows[e.NewEditIndex].FindControl("hcb联系人"); DropDownList ddl类别 = (DropDownList)grv.Rows[e.NewEditIndex].FindControl("ddl类别"); DropDownList ddl记录人 = (DropDownList)grv.Rows[e.NewEditIndex].FindControl("ddl记录人"); //FillDropDownList.FillHtmlCombxByTable(ref hcb事件来源, "DMIS_SYS_DEPART", "NAME", "ID", "order_id", "TYPE='自动化记事'"); FillDropDownList.FillHtmlCombxByTable(ref hcb厂站, "T_STATION_TYPE", "NAME", "TID", "NO"); FillDropDownList.FillByTable(ref ddl类别, "T_ZDH_记事_类别参数", "名称", "TID", "序号"); FillDropDownList.FillByTable(ref ddl记录人, "DMIS_VIEW_DEPART_MEMBER_ROLE", "MEMBER_NAME", "MEMBER_ID", "MEMBER_NAME", "ROLE_ID=4"); int tid = Convert.ToInt16(grv.DataKeys[e.NewEditIndex].Value); GridViewEdit.GridViewEditing(ref grv, tableID, e.NewEditIndex, tid); }
public void DropDownList(string prefix, string id, string value) { HtmlComboBox DropDownList = new HtmlComboBox(Doc); DropDownList.SearchProperties[HtmlRadioButton.PropertyNames.Id] = prefix + id; DropDownList.SelectedItem = value; }
public WebComboBox(List <UIProperty> controlProps) { BrowserWindow window = this.GetBrowser(controlProps); webcombo = new HtmlComboBox(window); controlProps.ForEach(property => webcombo.SearchProperties[property.PropertyName] = property.PropertyValue); }
//public void test() //{ // WinWindow win = this.UIWindowsSecurityWindow2; // if (!win.Exists) // Assert.Fail("no window"); // Keyboard.SendKeys(win, "Bus Sys"); // Keyboard.SendKeys(win, "{Tab}"); // Keyboard.SendKeys(win, Playback.EncryptText("Tottenham1")); // Keyboard.SendKeys(win, "Tottenham1"); // Playback.EncryptText("{Enter}"); //} /// <summary> /// MotoCreateSiteRenewal - Use 'MotoCreateSiteRenewalParams' to pass parameters into this method. /// </summary> public void MotoCreateSiteRenewal() { #region Variable Declarations HtmlHyperlink uICreateaMotorTestReneHyperlink = this.UIInsurEcomSystemMaintWindow.UILeftbarFrame.UIInsurEcomLeftbarDocument1.UIDivRenewalsPane.UICreateaMotorTestReneHyperlink; HtmlComboBox uIInsurerIDComboBox = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UIInsurerIDComboBox; HtmlEdit uITxtPolicyNumberEdit = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtPolicyNumberEdit; HtmlEdit uITxtAutoLapseDateEdit1 = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtAutoLapseDateEdit1; HtmlInputButton uICreateRecordButton = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UICreateRecordButton; BrowserWindow uIInsurEcomSystemMaintWindow = this.UIInsurEcomSystemMaintWindow; HtmlEdit uITxtRenewalDateEdit = this.UIInsurEcomSystemMaintWindow.UIContentFrame.UIInsurEcomMainPageDocument.UITxtRenewalDateEdit; #endregion // Click 'Create a Motor Test Renewal Invitation' link Mouse.Click(uICreateaMotorTestReneHyperlink, new Point(50, 22)); // Select 'Highway Insurance' in 'InsurerID' combo box uIInsurerIDComboBox.SelectedItem = this.MotoCreateSiteRenewalParams.UIInsurerIDComboBoxSelectedItem; // Type '7071000841' in 'txtPolicyNumber' text box uITxtPolicyNumberEdit.Text = this.MotoCreateSiteRenewalParams.UITxtPolicyNumberEditText; // Type '12/11/2012' in 'txtAutoLapseDate' text box uITxtAutoLapseDateEdit1.Text = uITxtRenewalDateEdit.GetProperty("Text").ToString(); // Click 'Create Record' button Mouse.Click(uICreateRecordButton, new Point(112, 11)); // Click 'Ok' button in the browser dialog window uIInsurEcomSystemMaintWindow.PerformDialogAction(BrowserDialogAction.Ok); }
public void HtmlComboBox_Items_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option>Cricket</option> <option>Football</option> <option>Tennis</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); //Act HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); //Assert Assert.AreEqual("Football", comboBox.Items[1]); Assert.IsTrue(comboBox.Items.Contains("Cricket")); browserWindow.Close(); } }
private static HtmlComboBox GetHtmlCombobox(string uiTitle, string uiType) { dynamic htmlControl = new HtmlComboBox(Browser.Locate(uiTitle, uiType)); htmlControl.TechnologyName = TechnologyNameWeb; return(htmlControl); }
public void SelectItem_UsingHtmlComboBoxThatAlertsOnChange_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId"" onchange=""alert('onchange');""> <option>Apple</option> <option>Banana</option> <option>Carrot</option> </select> </body> </html>")) { var window = BrowserWindow.Launch(webPage.FilePath); HtmlComboBox comboBox = window.Find <HtmlComboBox>(By.Id("selectId")); comboBox.SetFocus(); //Act // select item "Banana" Keyboard.SendKeys(comboBox.SourceControl, "{DOWN}"); window.PerformDialogAction(BrowserDialogAction.Ok); window.Close(); } }
public void InnerText_OnHtmlComboBoxWithDisabledItems_Succeeds() { //Arrange using (var webPage = new TempWebPage( @"<html> <head> <title>test</title> </head> <body> <select id=""selectId""> <option value=""1"">1</option> <option value=""2"" disabled=""disabled"">2</option> <option value=""3"" disabled=""disabled"">3</option> </select> </body> </html>")) { var browserWindow = BrowserWindow.Launch(webPage.FilePath); HtmlComboBox comboBox = browserWindow.Find <HtmlComboBox>(By.Id("selectId")); //Assert Assert.AreEqual(3, comboBox.ItemCount); CollectionAssert.AreEqual(new[] { "1", "2", "3" }, comboBox.Items); Assert.AreEqual("1 2 3", comboBox.InnerText.Trim()); browserWindow.Close(); } }
void Combobox(UITestControl parent, string id, string value) { var edit = new HtmlComboBox(parent); edit.SearchProperties.Add(HtmlComboBox.PropertyNames.Id, id); edit.SelectedItem = value; }
//填充HtmlComboBox控件 private void FillHtmlComboBox(ref HtmlComboBox hcb, string sql) { DataTable val = DBOpt.dbHelper.GetDataTable(sql); if (val == null) { return; } DataRow row = val.NewRow(); val.Rows.InsertAt(row, 0); //第一列是数据列 hcb.DataValueField = val.Columns[0].ColumnName; //如果有第二列,则是显示列,没有则第一列也是显示列。 if (val.Columns.Count > 1) { hcb.DataTextField = val.Columns[1].ColumnName; } else { hcb.DataTextField = val.Columns[0].ColumnName; } hcb.DataSource = val; hcb.DataBind(); }
public void SelectComboBoxItemList(UITestControl parent, string id, string item) { var list = new HtmlComboBox(parent); list.SearchProperties.Add(HtmlHyperlink.PropertyNames.Id, id); list.SelectedItem = item; }
// To select a value from HTML ComboBox based on single property public void selectHTMLComboBoxOneProp(string strControl, string strInput) { Keywords KeyFound = reader.FindControlinList(strControl); BrowserWindow _browser = new BrowserWindow(); HtmlComboBox _htmlComboBox = new HtmlComboBox(_browser); _htmlComboBox.SearchProperties.Add(KeyFound.PropertyName1, KeyFound.PropertyValue1); _htmlComboBox.SelectedItem = strInput; }
public void CodedUITestMethod1() { HtmlCustom brandAmazon = new HtmlCustom(br); brandAmazon.SearchProperties.Add(HtmlCustom.PropertyNames.TagName, "LI"); brandAmazon.SearchProperties.Add(HtmlCustom.PropertyNames.Class, "refinementImage"); //brandAmazon.DrawHighlight(); System.Drawing.Point myPoint = new System.Drawing.Point(100, 100); Mouse.Move(brandAmazon, myPoint); HtmlHyperlink bAmazonLink = new HtmlHyperlink(brandAmazon); bAmazonLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, " Amazon (1,156) "); bAmazonLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A"); bAmazonLink.DrawHighlight(); Mouse.Click(bAmazonLink); HtmlSpan facebookOption = new HtmlSpan(br); facebookOption.SearchProperties.Add(HtmlSpan.PropertyNames.TagName, "SPAN"); facebookOption.SearchProperties.Add(HtmlSpan.PropertyNames.Class, "bestLink"); facebookOption.SearchProperties.Add(HtmlSpan.PropertyNames.InnerText, "Facebook"); Mouse.Click(facebookOption); HtmlCustom searchSortForm = new HtmlCustom(br); searchSortForm.SearchProperties.Add(HtmlCustom.PropertyNames.TagName, "FORM"); searchSortForm.SearchProperties.Add(HtmlCustom.PropertyNames.Class, "sortByForm"); searchSortForm.DrawHighlight(); HtmlComboBox sort = new HtmlComboBox(searchSortForm); sort.SearchProperties.Add(HtmlComboBox.PropertyNames.Id, "sort"); sort.SearchProperties.Add(HtmlComboBox.PropertyNames.Name, "sort"); sort.SearchProperties.Add(HtmlComboBox.PropertyNames.Class, "sortByDropdown"); sort.SelectedIndex = 4; for (int i = 1; i <= 24; i++) { HtmlCustom giftTitle = new HtmlCustom(br); giftTitle.SearchProperties.Add(HtmlCustom.PropertyNames.TagName, "H3"); giftTitle.SearchProperties.Add(HtmlCustom.PropertyNames.InnerText, "Amazon.com Gift Cards - Facebook Delivery "); giftTitle.SearchProperties.Add(HtmlCustom.PropertyNames.TagInstance, "'" + i + "'"); giftTitle.DrawHighlight(); HtmlHyperlink giftTitle1 = new HtmlHyperlink(giftTitle); giftTitle1.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Amazon.com Gift Cards - Facebook Delivery"); giftTitle1.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A"); giftTitle1.SearchProperties.Add(HtmlHyperlink.PropertyNames.ClassName, "HtmlHyperlink"); string s = HtmlHyperlink.PropertyNames.FriendlyName; if (s == "Amazon.com Gift Cards - Facebook Delivery") { Console.WriteLine("Mathced!"); } } }
/// <summary> /// AssertMethod1 /// </summary> public void AssertMethod1() { #region Variable Declarations HtmlComboBox uIEmployeeComboBox = this.UIAbsenceWindowsInternWindow.UIAbsenceDocument.UIEmployeeComboBox; #endregion // Verify that 'Employee' combo box's property 'SelectedItem' is not equal to 'null' Assert.IsNotNull(uIEmployeeComboBox.SelectedItem); }
public EditWorkItemPage EditStatus(string itemName) { var uiDropdownStatus = new HtmlComboBox(browser); uiDropdownStatus.SearchProperties.Add(HtmlControl.PropertyNames.Id, EditWorkItemPageConst.EDIT_STATUS_DROPDOWN_ID); uiDropdownStatus.Find(); uiDropdownStatus.SetProperty(HtmlComboBox.PropertyNames.SelectedItem, itemName); return(this); }
public EditWorkItemPage EditProject(string itemName) { var uiDropdownProj = new HtmlComboBox(browser); uiDropdownProj.SearchProperties.Add(HtmlControl.PropertyNames.Id, EditWorkItemPageConst.EDIT_PROJECT_DROPDOWN_ID); uiDropdownProj.Find(); uiDropdownProj.SetProperty(HtmlComboBox.PropertyNames.SelectedItem, itemName); return(this); }
public void SelectQuestion(int questionIndex) { var element = new HtmlComboBox(mainpage); element.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "Question"); element.SearchProperties.Add(HtmlEdit.PropertyNames.Name, "Question"); element.SearchProperties.Add(HtmlEdit.PropertyNames.ControlType, "ComboBox"); element.SearchProperties.Add(HtmlEdit.PropertyNames.TagName, "SELECT"); element.SelectedIndex = questionIndex; }
public void SelectAddressType(string AddressType) { HtmlComboBox uIPageCombo = new HtmlComboBox(HeaderControls.EmpowerBrowserWindow.EmpowerHtmlDocument.AdminHtmlDocumentFrame.AdminHtmlDocument); uIPageCombo.SearchProperties[HtmlComboBox.PropertyNames.InnerText] = AddressType; uIPageCombo.SearchProperties[HtmlComboBox.PropertyNames.Id] = "ctl25_AddressTypeCodeID"; Playback.Wait(5000); Mouse.Click(uIPageCombo, MouseButtons.Left); }
public void SelectBusinessPartner() { Login1(); HtmlComboBox lstBusinessPartner = new HtmlComboBox(bw); HtmlComboBox lstLocation = new HtmlComboBox(bw); HtmlButton btnFinish = new HtmlButton(bw); lstBusinessPartner.SearchProperties.Add(HtmlListItem.PropertyNames.Id, "BusinessPartner"); lstLocation.SearchProperties.Add(HtmlListItem.PropertyNames.Id, "LocationId"); btnFinish.SearchProperties.Add(HtmlButton.PropertyNames.Id, "btn_finish"); UITestControlCollection col = lstBusinessPartner.FindMatchingControls(); List <HtmlComboBox> partners = new List <HtmlComboBox>(); if (col.Count > 0) { foreach (HtmlComboBox comboBox in col) { #region ricky /*if (lstBusinessPartner.Name == "BusinessPartnerId") * { * * UITestControlCollection col2 = comboBox.Items; * foreach (HtmlListItem item in col2) * { * * Playback.PlaybackSettings.DelayBetweenActions = 5000; * if (item.ValueAttribute == valueToSelect) * { * comboBox.SelectedItem = item.InnerText; * * Playback.PlaybackSettings.DelayBetweenActions = 5000; * break; * } * * } * }*/ #endregion int item = comboBox.SelectedIndex = 1; if (comboBox.SelectedIndex == 1) { lstBusinessPartner.SelectedItem = comboBox.SelectedItem; } } } Playback.PlaybackSettings.DelayBetweenActions = 10000; Mouse.Click(btnFinish); Playback.PlaybackSettings.DelayBetweenActions = 5000; OpenCashierArea(); OpenCashHouse(); }
private void ddl_SelectedIndexChanged(object sender, EventArgs e) { int pos = 0; //关联参数名称在tableParas中的位置 string sql; int counts = 0; Control cn; HtmlComboBox ddlNext; //被关联的参数 HtmlComboBox ddl = (HtmlComboBox)sender; //正在选择时的参数 int id = Convert.ToInt16(ddl.ID); CellReport report = (CellReport)ViewState["report"]; for (int i = 0; i <= report.Paras.GetUpperBound(0); i++) { if (report.Paras[i, 3] == id.ToString()) //此此参数被后面的关联 { cn = Page.FindControl(report.Paras[i, 0]); //被关联的控件 if (cn == null) { continue; } ddlNext = (HtmlComboBox)cn; ddlNext.Items.Clear(); for (int j = 0; j < report.TableParas.Count; j++) //扫描tableParas数组,看看所被关联参数如何从数据库中取值 { TablePara tp = (TablePara)report.TableParas[j]; TablePara tp2 = new TablePara(); if (tp.ParaCode == (":" + i.ToString())) { pos = j; tp2 = (TablePara)report.TableParas[pos]; } if (":" + report.Paras[i, 0] == tp.ParaCode) { ddlNext.Items.Clear(); ddlNext.Text = ""; sql = "select distinct " + tp2.ColumnName + " from " + tp2.TableName + " where " + tp2.ColumnName + "='" + ddl.SelectedValue + "'"; DbDataReader drValue = DBOpt.dbHelper.GetDataReader(sql); while (drValue.Read()) { if (counts > 99) { break; //只放100个值 } ddlNext.Items.Add(drValue[0].ToString().Trim()); } drValue.Close(); } } } } }
public static void FillHtmlCombxByTable(ref HtmlComboBox hcb, string TableName, string TextColumn, string ValueColumn, string Orders, string Wheres) { string sql; sql = "select " + ValueColumn + "," + TextColumn + " from " + TableName + " where " + Wheres + " order by " + Orders; DataTable dt = DBOpt.dbHelper.GetDataTable(sql); hcb.Items.Clear(); hcb.DataTextField = TextColumn; hcb.DataValueField = ValueColumn; hcb.DataSource = dt; hcb.DataBind(); }
public void HtmlComboBoxTest_SelectedItem() { HtmlComboBox comboBox = new HtmlComboBox(BasicTestPage); string coffee = "Coffee"; string tea = "Tea"; comboBox.SelectedItem = coffee; comboBox.SelectedItem.Should().Be(coffee); AssertResult("comboBox", "click"); comboBox.SelectedItem = tea; comboBox.SelectedItem.Should().Be(tea); AssertResult("comboBox", "click"); }
public static void SelectDropdownByIndex(int index) { var dropdownControl = new HtmlComboBox(browserWindow); try { dropdownControl.SearchProperties[CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType] = CSVReader.LocatorValue; dropdownControl.WaitForControlEnabled(); dropdownControl.WaitForControlReady(); } catch (Exception) { Assert.Fail("Failed to find " + CSVReader.ControlType + " Element - Element not Found"); } dropdownControl.SelectedIndex = index; }
public void CodedUITestMethod1() { int value = 1; BrowserWindow window = BrowserWindow.Launch("http://automationpractice.com/index.php"); Thread.Sleep(3000); HtmlDiv dresslinkParent = new HtmlDiv(window); dresslinkParent.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "block_top_menu"); //dresslinkParent.DrawHighlight(); HtmlHyperlink DressesLink = new HtmlHyperlink(dresslinkParent); //DressesLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A"); DressesLink.SearchProperties[HtmlHyperlink.PropertyNames.InnerText] = "Dresses"; //this.mUIDressesHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.AbsolutePath] = "/index.php"; //this.mUIDressesHyperlink.FilterProperties[HtmlHyperlink.PropertyNames.Title] = "Dresses"; DressesLink.SearchProperties.Add(HtmlHyperlink.PropertyNames.Title, "Dresses"); var col = DressesLink.FindMatchingControls(); //col[1].DrawHighlight(); Mouse.Hover(col[1]); Thread.Sleep(1000); HtmlHyperlink summerDresses = new HtmlHyperlink(dresslinkParent); summerDresses.SearchProperties.Add(HtmlHyperlink.PropertyNames.TagName, "A"); summerDresses.SearchProperties.Add(HtmlHyperlink.PropertyNames.InnerText, "Summer Dresses".ToUpper()); col = summerDresses.FindMatchingControls(); //col[0].DrawHighlight(); //col[1].DrawHighlight(); Mouse.Click(col[1]); HtmlCheckBox checkbog = new HtmlCheckBox(window); checkbog.SearchProperties.Add(HtmlCheckBox.PropertyNames.Id, "layered_id_attribute_group_1"); if (checkbog.Checked == false) { checkbog.Checked = true; } HtmlComboBox combobo = new HtmlComboBox(); combobo.SelectedItem = "value"; HtmlRadioButton butt = new HtmlRadioButton(); butt.Selected = false; butt.WaitForControlEnabled(); }
public void HtmlComboBoxTest_SelectedIndex() { HtmlComboBox comboBox = new HtmlComboBox(BasicTestPage); int expectedValue = 1; comboBox.SelectedIndex = expectedValue; comboBox.SelectedIndex.Should().Be(expectedValue); comboBox.SelectedItem.Should().Be("Coffee"); AssertResult("comboBox", "click"); expectedValue = 2; comboBox.SelectedIndex = expectedValue; comboBox.SelectedIndex.Should().Be(expectedValue); comboBox.SelectedItem.Should().Be("Tea"); AssertResult("comboBox", "click"); }
public static void SelectDropdownByText(string text) { var dropdownControl = new HtmlComboBox(browserWindow); try { dropdownControl.SearchProperties[CSVReader.ControlType + ".PropertyNames." + CSVReader.LocatorType] = CSVReader.LocatorValue; dropdownControl.WaitForControlEnabled(); dropdownControl.WaitForControlReady(); } catch (Exception) { Assert.Fail("Failed to find " + CSVReader.ControlType + " Element - Element not Found"); } if (!dropdownControl.SelectedItem.Equals(text)) { foreach (var t in dropdownControl.Items.Where(t => t.Name == text)) { dropdownControl.SelectedItem = text; break; } } }
public WebComboBox(List<UIProperty> controlProps) { BrowserWindow window = this.GetBrowser(controlProps); webcombo = new HtmlComboBox(window); controlProps.ForEach(property => webcombo.SearchProperties[property.PropertyName] = property.PropertyValue); }
public void AddData(string filename, string testcase) { DataTable dt1 = hlp.dtFromExcelFile(filename, "Template"); DataTable dt2 = hlp.dtFromExcelFile(filename, "ExpectedData", "TestCase", testcase); UITestControl UIcurrentparent = null; for (int i = 0; i < dt1.Rows.Count; i++) { string controlValue = ""; string parentType = dt1.Rows[i]["ParentType"].ToString(); string parentSearchBy = dt1.Rows[i]["parentSearchBy"].ToString(); string parentSearchValue = dt1.Rows[i]["parentSearchValue"].ToString(); string pTechnology = dt1.Rows[i]["Technology"].ToString(); string controlType = dt1.Rows[i]["ControlType"].ToString(); string technologyControl = dt1.Rows[i]["TechnologyControl"].ToString(); string field = dt1.Rows[i]["Field"].ToString(); string index = dt1.Rows[i]["Index"].ToString(); string searchBy = dt1.Rows[i]["SearchBy"].ToString(); string searchValue = dt1.Rows[i]["SearchValue"].ToString(); string pOperator = dt1.Rows[i]["pOperator"].ToString(); string cOperator = dt1.Rows[i]["cOperator"].ToString(); if (field.Length > 0) { controlValue = dt2.Rows[0][field].ToString(); } if (parentType.Length > 0) { switch (parentType.ToLower()) { #region Window case "window": { if (pTechnology.ToLower() == "msaa") { WinWindow uiwindow = new WinWindow(); if (pOperator == "=") { uiwindow.SearchProperties.Add(parentSearchBy, parentSearchValue); } else if (pOperator == "~") { uiwindow.SearchProperties.Add(parentSearchBy, parentSearchValue, PropertyExpressionOperator.Contains); } UIcurrentparent = uiwindow; } else if (pTechnology == "uia") { WpfWindow uiwindow = new WpfWindow(); if (pOperator == "=") { uiwindow.SearchProperties.Add(parentSearchBy, parentSearchValue); } else if (pOperator == "~") { uiwindow.SearchProperties.Add(parentSearchBy, parentSearchValue, PropertyExpressionOperator.Contains); } UIcurrentparent = uiwindow; } break; } #endregion #region client case "client": { if (pTechnology.ToLower() == "msaa") { WinClient uicleint = new WinClient(UIcurrentparent); if (pOperator == "=") { uicleint.SearchProperties.Add(parentSearchBy, parentSearchValue); } else if (pOperator == "~") { uicleint.SearchProperties.Add(parentSearchBy, parentSearchValue, PropertyExpressionOperator.Contains); } UIcurrentparent = uicleint; } else if (pTechnology.ToLower() == "uia") { // to do } break; } #endregion #region docuemnt case "document": { if (pTechnology.ToLower() == "web") { HtmlDocument uidoc = new HtmlDocument(UIcurrentparent); if (pOperator == "=") { uidoc.SearchProperties.Add(parentSearchBy, parentSearchValue); } else if (pOperator == "~") { uidoc.SearchProperties.Add(parentSearchBy, parentSearchValue, PropertyExpressionOperator.Contains); } UIcurrentparent = uidoc; } else if (pTechnology.ToLower() == "uia") { // to do } break; } #endregion } } if (controlType.Length > 0) { switch (controlType.ToLower()) { #region edit case "edit": { if (technologyControl == "MSAA") { // to do } else if (technologyControl == "UIA") { // to do } else if (technologyControl == "Web") { HtmlEdit uiedit = new HtmlEdit(UIcurrentparent); if (cOperator == "=") { uiedit.SearchProperties.Add(searchBy, searchValue); } else if (cOperator == "~") { uiedit.SearchProperties.Add(searchBy, searchValue, PropertyExpressionOperator.Contains); } if (controlValue.Length > 0) { uiedit.Text = controlValue; } } break; } #endregion #region button case "button": { if (technologyControl == "MSAA") { // to do } else if (technologyControl == "UIA") { // to do } else if (technologyControl == "Web") { HtmlButton ucntl= new HtmlButton(UIcurrentparent); if (cOperator == "=") { ucntl.SearchProperties.Add(searchBy, searchValue); if (index.Length > 0) { ucntl.SearchProperties.Add("TagInstance", index); } } else if (cOperator == "~") { ucntl.SearchProperties.Add(searchBy, searchValue, PropertyExpressionOperator.Contains); } if (controlValue.Length > 0) { Mouse.Click(ucntl); } } break; } #endregion #region image case "image": { if (technologyControl == "MSAA") { // to do } else if (technologyControl == "UIA") { // to do } else if (technologyControl == "Web") { HtmlImage ucntl = new HtmlImage(UIcurrentparent); if (cOperator == "=") { ucntl.SearchProperties.Add(searchBy, searchValue); if (index.Length > 0) { ucntl.SearchProperties.Add("TagInstance", index); } } else if (cOperator == "~") { ucntl.SearchProperties.Add(searchBy, searchValue, PropertyExpressionOperator.Contains); } if (controlValue.Length > 0) { Mouse.Click(ucntl); } } break; } #endregion #region Dropdown case "dropdown" : { if (technologyControl == "MSAA") { // to do } else if (technologyControl == "UIA") { // to do } else if (technologyControl == "Web") { HtmlComboBox ucntl = new HtmlComboBox(UIcurrentparent); if (cOperator == "=" ) { if (searchValue.Length > 0) { ucntl.SearchProperties.Add(searchBy, searchValue); } if (index.Length > 0) { ucntl.SearchProperties.Add("TagInstance", index); } } else if (cOperator == "~") { ucntl.SearchProperties.Add(searchBy, searchValue, PropertyExpressionOperator.Contains); } if (controlValue.Length > 0) { ucntl.SelectedItem = controlValue; hlp.LogtoTextFile("Entered Value in ComboBox"); } } break; } #endregion } } } }