public static void Select(this Ranorex.ComboBox combobox, string item) { // create button Ranorex.Button mybutton = combobox.FindSingle(combobox.GetPath().ToString() + "/button[@accessiblename='Open' or @text='>']"); mybutton.Click(); // create list item to click on Ranorex.ListItem myList = combobox.FindSingle(String.Format("/list[@controlid='1000']/listitem[@text='{0}']", item)); myList.Click(); }
// public static void ConnectDMRepo() // { // try // { // repo.Application.File.Click(); // Reports.ReportLog("Clicked File Menu Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // repo.SQLdmDesktopClient.ConnectToSQLDMRepository.Click(); // Reports.ReportLog("Clicked Menuitem ConnectToSQLDMRepository Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // Ranorex.ComboBox combobox = repo.RepositoryConnectionDialog.AuthenticationDropDownList; // combobox.Click(); // ListItem lst_userItem = combobox.FindSingle<ListItem>("/list/listitem[@text='SQL Server Authentication']"); // lst_userItem.Focus(); // lst_userItem.Click(); // Reports.ReportLog("SQL Server Authentication Selected ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // repo.RepositoryConnectionDialog.Username.PressKeys(Constants.SqlSystemUser); // Reports.ReportLog("Username : "******"Entered Successfully " , Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // // repo.RepositoryConnectionDialog.Password.PressKeys(Constants.SqlSystemUserPassword); // Reports.ReportLog("Passsword Entered Successfully " , Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // repo.RepositoryConnectionDialog.ConnectButton.ClickThis(); // Reports.ReportLog("Clicked Connect Button Successfully ! " , Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // // if(repo.Application.CaptionText.TextValue.Contains(Constants.SQLdmRepository)) // Reports.ReportLog("Connected to SQLdmRepository Successfully ! " , Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); // else // { // Reports.ReportLog("Failed to connect to SQLdmRepository " , Reports.SQLdmReportLevel.Fail, null, Configuration.Config.TestCaseName); // throw new Exception("Failed to connect to SQLdmRepository "); // } // } // catch(Exception ex) // { // throw new Exception("Failed : ConnectDMRepo : " + ex.Message); // } // } public static void ConnectDMRepo(string userType) { try { repo.Application.File.Click(); Reports.ReportLog("Clicked File Menu Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); repo.SQLdmDesktopClient.ConnectToSQLDMRepository.Click(); Reports.ReportLog("Clicked Menuitem ConnectToSQLDMRepository Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); if (userType.Equals(Constants.SqlUser)) { Ranorex.ComboBox combobox = repo.RepositoryConnectionDialog.AuthenticationDropDownList; combobox.Click(); ListItem lst_userItem = combobox.FindSingle <ListItem>("/list/listitem[@text='SQL Server Authentication']"); lst_userItem.Focus(); lst_userItem.Click(); Reports.ReportLog("SQL Server Authentication Selected ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); repo.RepositoryConnectionDialog.Username.PressKeys(Constants.NewSqlUser); Reports.ReportLog("Username : "******"Entered Successfully ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); repo.RepositoryConnectionDialog.Password.PressKeys(Constants.NewSqlUserPassword); Reports.ReportLog("Passsword Entered Successfully ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); } else { Ranorex.ComboBox combobox = repo.RepositoryConnectionDialog.AuthenticationDropDownList; combobox.Click(); ListItem lst_userItem = combobox.FindSingle <ListItem>("/list/listitem[@text='Windows Authentication']"); lst_userItem.Focus(); lst_userItem.Click(); Reports.ReportLog("Windows Authentication Selected ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); } repo.RepositoryConnectionDialog.ConnectButton.ClickThis(); Reports.ReportLog("Clicked Connect Button Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); if (repo.Application.CaptionText.TextValue.Contains(Constants.SQLdmRepository)) { Reports.ReportLog("Connected to SQLdmRepository Successfully ! ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); } else { Reports.ReportLog("Failed to connect to SQLdmRepository ", Reports.SQLdmReportLevel.Fail, null, Configuration.Config.TestCaseName); throw new Exception("Failed to connect to SQLdmRepository "); } Thread.Sleep(30000); } catch (Exception ex) { throw new Exception("Failed : ConnectDMRepo : " + ex.Message); } }
public static void SelectSqlAuthentication() { try { Ranorex.ComboBox combobox = repo.AddPermissionWizard.ComboBoxUserPageCmbBxAuthentication; combobox.Click(); ListItem lst_userItem = combobox.FindSingle <ListItem>("/list/listitem[@text='SQL Server Authentication']"); lst_userItem.Focus(); lst_userItem.Click(); Reports.ReportLog("SQL Server Authentication Selected ", Reports.SQLdmReportLevel.Success, null, Configuration.Config.TestCaseName); } catch (Exception ex) { throw new Exception("Failed : SelectAuthenticationType : " + ex.Message); } }
//********************************************************************** /// <summary> /// Form action: VerifyProperty equal, Contains, NotContains. /// </summary> public static void VerifyProperty(LxScriptItem item) { //MessageBox.Show(item.getComponent().ToString()); // The component is lable string testtemp = item.getComponent().ToString(); if (item.getComponent().ToString().IndexOf("Lbl") != -1) { Ranorex.NativeWindow nativeWnd = item.getComponentInfo().CreateAdapter <Ranorex.NativeWindow>(false); string lableText = nativeWnd.WindowText; if (item.getArg2Text() == "Equal") { string abc = item.getArg3Text(); Validate.AreEqual(lableText, item.getArg3Text()); } if (item.getArg2Text() == "Contains") { int iFlag = lableText.IndexOf(item.getArg3Text()); Validate.IsTrue(iFlag != -1); } if (item.getArg2Text() == "NotContains") { int iFlag = lableText.IndexOf(item.getArg3Text()); Validate.IsTrue(iFlag == -1); } return; } if (item.getArg2Text() == "Equal") { Validate.Attribute(item.getComponentInfo(), item.getArgText(), item.getArg3Text()); } if (item.getArg2Text() == "Contains") { Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex(Regex.Escape(item.getArg3Text()))); } if (item.getArg2Text() == "NotContains") { Validate.Attribute(item.getComponentInfo(), item.getArgText(), new Regex("^((?!(" + Regex.Escape(item.getArg3Text()) + ")).)*$")); } if (item.getArg2Text() == "ListContains") { bool Resultflag = false; object objComponet = item.getComponent(); Ranorex.ComboBox myComboBox = (Ranorex.ComboBox)(objComponet); Ranorex.Button btn = myComboBox.FindSingle("./button"); btn.Click(); List lst = "/list"; foreach (ListItem lst_item in lst.FindChildren <ListItem>()) { if ((lst_item.Text).Equals(item.getArg3Text())) { Resultflag = true; break; } } btn.Click(); Validate.AreEqual(Resultflag, true); } }