public static void If_Application_Is_Not_unInstall(string UninstallBuildname) { try { Ranorex.Text App_uninstall = "/form[@title~'Smart Fit' or @title~'Solus Max' or @title~'Audigy']/text[@windowtext~'A newer or same version of this application is already installed on this computer. If you wish to install this version, please uninstall the installed version first.']"; if (App_uninstall.Visible == true) { Ranorex.Button btnOk = "/form[@title~'Smart Fit' or @title~'Solus Max' or @title~'Audigy']/button[@text='OK']"; Mouse.Click(btnOk); Delay.Seconds(5); Process p = new Process(); Delay.Seconds(3); p.StartInfo.FileName = @"D:\TFS\FSW\TestSuites\Market_Preferences\Builds\" + UninstallBuildname + "\\Setup.exe"; // p.StartInfo.FileName = @"~\Desktop\Market_Preferences\Builds\"+UninstallBuildname+"\\Setup.exe"; p.StartInfo.Arguments = "/x /v/qn"; p.Start(); Delay.Seconds(5); } } catch { Ranorex.Button cancelbtn = "/form[@title~'Smart Fit' or @title~'Solus Max' or @title~'Audigy']/button[@text='Cancel']"; Mouse.Click(cancelbtn); Delay.Seconds(3); } }
private void CreateRedLetterDayWithDragNDrop() { //calendar.MainForm.Self.Activate(); System.DateTime day1; System.DateTime day2; string strday1, strday2; calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnNewAppointment.Click(); Delay.Seconds(1); calendar.EventDetailForm.PnlBase.txtAppointmentTitle.PressKeys(data); cmn.SelectItemDropdown(calendar.EventDetailForm.PnlBase.SelectEvent, "Red Letter Day", "Event Type Dropdown"); calendar.EventDetailForm.btnOK.Click(); Delay.Seconds(3); calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnViewMenu.Click(); calendar.MainForm.menuListView.Click(); Delay.Seconds(3); cmn.VerifyDataExistsInTable(calendar.MainForm.tblCalendar, data, "Calendar List"); calendar.MainForm.Toolbar.btnWeek.Click(); day1 = System.DateTime.Now; day2 = day1.AddDays(1); strday1 = day1.ToString("MMMM d, yyyy"); strday2 = day2.ToString("MMMM d, yyyy"); calendar.curwkday = strday1; calendar.MainForm.PnlViews.shrtDay.Click(); calendar.appmtData = data; //calendar.MainForm.PnlViews.txtappointment; Delay.Seconds(2); Ranorex.Text sourceappt = calendar.MainForm.PnlViews.txtappointment; calendar.curwkday = strday2; DragNDropLibrary.DragAndDrop(sourceappt, calendar.MainForm.PnlViews.shrtDay); }
public static bool ClickThis(this Ranorex.Text item) { System.Threading.Thread.Sleep(sleepTime); item.Click(); System.Threading.Thread.Sleep(sleepTime); return(true); }
private void CreateRepeatedAppointment() { System.DateTime day1; System.DateTime day2; string strday1, strday2; calendar.MainForm.Self.Activate(); calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnNewAppointment.Click(); Delay.Seconds(1); calendar.EventDetailForm.PnlBase.txtAppointmentTitle.PressKeys(data); calendar.EventDetailForm.PnlBase.txtStartTime.PressKeys(System.DateTime.Now.ToShortTimeString()); calendar.EventDetailForm.PnlBase.txtEndTime.PressKeys(System.DateTime.Now.AddHours(1).ToShortTimeString()); calendar.EventDetailForm.PnlBase.Repeat.Click(); cmn.SelectItemDropdown(calendar.EventDetailForm.PnlBase.cmbbxRepeat, "Weekly", "Repeat Dropdown"); calendar.weekday = System.DateTime.Now.ToString("ddd"); calendar.EventDetailForm.PnlBase.cbWeekday.Check(); Delay.Seconds(1); calendar.weekday = System.DateTime.Now.AddDays(1).ToString("ddd"); calendar.EventDetailForm.PnlBase.cbWeekday.Check(); cmn.SelectItemDropdown(calendar.EventDetailForm.PnlBase.cmbbxHolidayRule, "Cancel that occurrence", "Holiday Rule Dropdown"); calendar.EventDetailForm.btnOK.Click(); Delay.Seconds(3); AppointmentOverlapPrompt(); ValidateEventRemainderPopup(); calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnViewMenu.Click(); calendar.MainForm.menuListView.Click(); Delay.Seconds(3); cmn.VerifyDataExistsInTable(calendar.MainForm.tblCalendar, data, "Calendar List"); calendar.MainForm.Toolbar.btnWeek.Click(); day1 = System.DateTime.Now; day2 = day1.AddDays(2); strday1 = day1.ToString("MMMM d, yyyy"); strday2 = day2.ToString("MMMM d, yyyy"); calendar.curwkday = strday1; calendar.MainForm.PnlViews.shrtDay.Click(); calendar.appmtData = data; //calendar.MainForm.PnlViews.txtappointment; Delay.Seconds(2); Ranorex.Text sourceappt = calendar.MainForm.PnlViews.txtappointment; calendar.curwkday = strday2; DragNDropLibrary.DragAndDrop(sourceappt, calendar.MainForm.PnlViews.shrtDay); Delay.Seconds(2); Validate.Exists(calendar.RepeatingEventDialogForm.SelfInfo, "Repeating Event Exception Dialog is seen"); calendar.RepeatingEventDialogForm.Toolbar1.btnThisOne.Click(); Delay.Seconds(2); calendar.curwkday = strday2; calendar.MainForm.PnlViews.shrtDay.Click(); calendar.appmtData = data; Validate.Exists(calendar.MainForm.PnlViews.txtappointmentInfo, "Appt Moved to a new Date"); }
public static void RightClick(this Ranorex.Text item) { try { Mouse.Click(item, System.Windows.Forms.MouseButtons.Right, new Point(30, 10)); } catch (Exception ex) { throw new Exception("Text Right Click Failed : " + ex.Message); } }
public static void ClickThis(this Ranorex.Text item) { try { item.Click(); Sleep(); } catch (Exception ex) { throw new Exception("Text Click Failed : " + ex.Message); } }
public static void TextBoxText(this Ranorex.Text item, string value) { try { item.TextValue = value; Sleep(); } catch (Exception ex) { throw new Exception("Textbox text Failed to set : " + ex.Message); } }
private void CreateAdjrnApptWithDragnDrop() { string new_Data = ""; string strday1, strday2; System.DateTime day1, day2; calendar.MainForm.Self.Activate(); calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnNewAppointment.Click(); Delay.Seconds(1); calendar.EventDetailForm.PnlBase.txtAppointmentTitle.PressKeys(data); calendar.EventDetailForm.PnlBase.txtStartTime.PressKeys(System.DateTime.Now.ToShortTimeString()); calendar.EventDetailForm.PnlBase.txtEndTime.PressKeys(System.DateTime.Now.AddHours(1).ToShortTimeString()); calendar.EventDetailForm.PnlBase.cbMilestone.Check(); calendar.EventDetailForm.PnlBase.cbShowAdjournments.Check(); calendar.EventDetailForm.btnOK.Click(); Delay.Seconds(3); AppointmentOverlapPrompt(); ValidateEventRemainderPopup(); calendar.MainForm.btnCalendar.Click(); calendar.MainForm.btnViewMenu.Click(); calendar.MainForm.menuListView.Click(); Delay.Seconds(3); new_Data += "Milestone: " + data; cmn.VerifyDataExistsInTable(calendar.MainForm.tblCalendar, new_Data, "Calendar List"); calendar.MainForm.Toolbar.btnWeek.Click(); day1 = System.DateTime.Now; day2 = day1.AddDays(2); strday1 = day1.ToString("MMMM d, yyyy"); strday2 = day2.ToString("MMMM d, yyyy"); calendar.curwkday = strday1; calendar.MainForm.PnlViews.shrtDay.Click(); calendar.appmtData = data; Delay.Seconds(2); Validate.Exists(calendar.MainForm.PnlViews.txtappointmentInfo, "Adjourned Appointment present as expected"); Ranorex.Text sourceappt = calendar.MainForm.PnlViews.txtappointment; calendar.curwkday = strday2; DragNDropLibrary.DragAndDrop(sourceappt, calendar.MainForm.PnlViews.shrtDay); Delay.Seconds(2); Validate.Exists(calendar.AdjournmentReasonForm.SelfInfo, "Adjournment Reason Form"); calendar.AdjournmentReasonForm.txtAdjournReason.Click(); calendar.AdjournmentReasonForm.txtAdjournReason.PressKeys(String.Format("Moving 2 days from current Day {0}", System.DateTime.Now.ToShortDateString())); calendar.AdjournmentReasonForm.Toolbar1.ButtonOK.Click(); calendar.curwkday = strday2; calendar.MainForm.PnlViews.shrtDay.Click(); calendar.appmtData = data; Validate.Exists(calendar.MainForm.PnlViews.txtappointmentInfo, "Master Instance of the new Appointment Exists as expected"); }
public static void EnterDevicename(string devicename) { Ranorex.Text DeviceselectionTextbox = "/form[@name~'Smart Fit' or @name~'Launcher' or @name~'Solus Max' or @name~'Interton Fitting' or @name~'Audigy' or @name~'Costco' or @classname='Window']/text"; //if the Device name Ends with 'P',it will delete the Last three character of the Device name and Enters in Textbox if (devicename.EndsWith("P")) { devicename = devicename.Substring(0, devicename.Length - 3); DeviceselectionTextbox.TextValue = devicename; } else { DeviceselectionTextbox.TextValue = devicename; } }
public static void Select_Device(string devicename) { Ranorex.Text DeviceselectionTextbox = "/form[@name~'Smart Fit' or @name~'Launcher' or @name~'Solus Max' or @name~'Interton Fitting' or @name~'Audigy' or @name~'Costco' or @classname='Window']/text"; Ranorex.Container DeviceContainer = "/contextmenu[@processname~'SmartFit' or @processname~'SolusMax' or @processname~'Audigy' or @processname~'Interton']/list/container/container"; IList <ListItem> txtlistitem = DeviceContainer.FindChildren <ListItem>(); for (int i = 0; i <= txtlistitem.Count - 1; i++) { int j = i + 1; Ranorex.ListItem device = "/contextmenu[@processname~'SmartFit' or @processname~'SolusMax' or @processname~'Audigy' or @processname~'Interton']/list/container/container/listitem[" + j + "]"; string k = device.Text; if (devicename == k || k == DeviceselectionTextbox.TextValue) { Mouse.Click(device); break; } } }
public static bool TextBoxText(this Ranorex.Text item, string value) { item.TextValue = value; return(true); }
public static void SetFieldText(this Ranorex.Text fieldtxt, string elementNum, string txt) { Text.FromElement(String.Format("?/?/element[@controlid='{0}']/text[@accessiblerole='Text']", elementNum)).PressKeys(txt); }
// // public static void Select(this Ranorex.ComboBox combobox, string item) // { // int index = 0; // // IList<ListItem> lTemp = combobox.Items; // // foreach(ListItem currentItem in lTemp) // { // if(currentItem.Text == item) // { // break; // } // index++; // } // combobox.Items[index].Select(); // } public static string GetFieldText(this Ranorex.Text fieldtext, string elementNum) { return(Text.FromElement(String.Format("?/?/element[@controlid='{0}']/text[@accessiblerole='Text']", elementNum)).TextValue); }
public static string RestartSystemX(bool autoLogin = true) { string response = "Det oppsto kritisk feil på den foregående test. Starte System X program"; try { // Kill System X process Process systemxProcess = Process.GetProcessesByName("Systemx")[0]; systemxProcess.Kill(); Delay.Seconds(2); KillCrashProgram(); try { // Get the System X path and run it string appName = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SystemxPath.log"); Process.Start(appName); // If System X is not properly terminated, this window will popup try { Ranorex.Form frmProgFail = Host.Local.FindSingle <Ranorex.Form>("/form[@title='Bekreft']", 5000); frmProgFail.PressKeys("{ESCAPE}"); } catch (ElementNotFoundException) { // Do nothing } if (autoLogin) { try { // Get login details string[] details = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\login.log").Split(';'); string username = details[0]; string password = details[1]; try { Ranorex.Text txtUsername = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='UsrName']", 2000); Ranorex.Text txtPassword = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='PWord']", 2000); txtUsername.Focus(); txtUsername.PressKeys(username); txtPassword.Focus(); txtPassword.PressKeys(password); Ranorex.Form frmCalendar = Host.Local.FindSingle <Ranorex.Form>("/form[@controlname='fdt']", 3000); frmCalendar.Activate(); frmCalendar.PressKeys("{ENTER}"); Delay.Seconds(2); } catch (ElementNotFoundException) { //Do nothing } } catch (FileNotFoundException) { response = "Kan ikke logge inn automatisk. Finner ikke loggfilen som inneholder de siste innloggingsdetaljer"; } } } catch (FileNotFoundException) { response = "Kan ikke starte System X. Loggfilen som inneholder mangler System X stien"; } } catch (IndexOutOfRangeException) { response = "Kan ikke avslutte System X prosess. Kan ikke finne prosessnavnet"; } return(response); }
public void ThenTheLabelIsEmpty() { Ranorex.Text lblCaption = "/form[@name='Form1']/text[@name='Label1']"; Validate.Equals(lblCaption.TextValue, ""); }
public void ThenTheLabelShouldShowHelloWorld() { Ranorex.Text lblCaption = "/form[@name='Form1']/text[@name='Label1']"; Validate.Equals(lblCaption.TextValue, "Hello World!"); }