/// <summary> /// AssertMethod1 - Use 'AssertMethod1ExpectedValues' to pass parameters into this method. /// </summary> public void AssertMethod1() { #region Variable Declarations XamlButton uISetValueButton = this.UISampleApplicationWindow.UISetValueButton; #endregion // Verify that the 'AutomationId' property of 'Set Value' button equals 'btn_Set' Assert.AreEqual(this.AssertMethod1ExpectedValues.UISetValueButtonAutomationId, uISetValueButton.AutomationId); }
/// <summary> /// AssertMethod1 - Use 'AssertMethod1ExpectedValues' to pass parameters into this method. /// </summary> public async void AssertMethod1() { #region Variable Declarations XamlButton uIAddMusicButton = this.UIBassBoosterWindow.UIAddMusicButton; XamlEdit uILyricsTextBoxEdit = this.UIBassBoosterWindow.UIItemPane.UILyricsTextBoxEdit; #endregion await Task.Delay(100000); //doesnt work // Verify that the 'ControlType' property of 'Add Music' button equals 'Button' Assert.AreEqual(this.AssertMethod1ExpectedValues.UIAddMusicButtonControlType, uIAddMusicButton.ControlType.ToString(), "aaa"); // Verify that the 'ControlType' property of 'LyricsTextBox' text box contains 'Sometime I just' StringAssert.Contains(uILyricsTextBoxEdit.ControlType.ToString(), this.AssertMethod1ExpectedValues.UILyricsTextBoxEditControlType, "FAil"); }
/// <summary> /// AssertMethod1 - Use 'AssertMethod1ExpectedValues' to pass parameters into this method. /// </summary> public void AssertMethod1() { #region Variable Declarations UITestControl uITake158GetdownatyourText = this.UIItemWindow.UIScrollerPane.UITake158GetdownatyourText; XamlEdit start = this.UICeylonBusRoutesWindow.UITextStartGroup.UITextBoxEdit; XamlEdit end = this.UICeylonBusRoutesWindow.UITextEndGroup.UITextBoxEdit; XamlButton search = this.UICeylonBusRoutesWindow.UIBestRoutesButton; start.Text = "Moratuwa"; end.Text = "Piliyandala"; Gesture.Tap(search); #endregion // Verify that the 'ControlType' property of 'Take 158 . Get down at your destination, Piliyanda...' label equals 'Take 158. Get down at your destination, Piliyandala' Assert.AreEqual("Take 158. Get down at your destination, Piliyandala", uITake158GetdownatyourText, "Wrong Value"); }
public void Test_ValuePattern() { //Launch app XamlWindow samplewindow = XamlWindow.Launch( "10da12ee-a022-4719-88bb-93272747b2c1_3gp2x379966ha!App"); System.Threading.Thread.Sleep(3000); XamlWindow MS_XAML_DateTimeSelector_UIATest = new XamlWindow(); MS_XAML_DateTimeSelector_UIATest.SearchProperties[XamlWindow.PropertyNames.Name] = "DateTimeSelector_UIATest2015"; var DateTimeSelector_UIATest = AutomationElement.RootElement.FindFirst (TreeScope.Children, new System.Windows.Automation.PropertyCondition(AutomationElement.NameProperty, "DateTimeSelector_UIATest2015")); DateTimeSelector_UIATest = DateTimeSelector_UIATest.FindFirst(TreeScope.Children, Condition.TrueCondition); var datetimeselector = DateTimeSelector_UIATest.FindFirst(TreeScope.Children, new System.Windows.Automation.PropertyCondition(AutomationElement.AutomationIdProperty, "datetimeselector")); //Tap the button (in which "3/19/2010" date is set to SelectedDate) var btn_Set = new XamlButton(MS_XAML_DateTimeSelector_UIATest); btn_Set.SearchProperties[XamlButton.PropertyNames.AutomationId] = "btn_Set"; Gesture.Tap(btn_Set); //CodedUI does not recognize DateSelector control , so we can't use valuepattern //var DateEditor = new XamlControl(MS_XAML_DateTimeSelector_UIATest); //DateEditor.SearchProperties[XamlControl.PropertyNames.AutomationId] = "DateEditor"; //var msg = "Before:" + DateEditor.FriendlyName; //object _valuepattern = null; //if (datetimeselector.TryGetCurrentPattern(ValuePattern.Pattern, out _valuepattern)) //{ // ((ValuePattern)_valuepattern).SetValue("10/23/2010"); //} //msg += ".After:" + DateEditor.FriendlyName; //Assert.AreEqual("Before:3/19/2010.After:10/23/2010", msg); System.Threading.Thread.Sleep(2000); var msg = "Before:" + GetDateTime(MS_XAML_DateTimeSelector_UIATest); XamlComboBox CboDays = new XamlComboBox(MS_XAML_DateTimeSelector_UIATest); CboDays.SearchProperties[XamlComboBox.PropertyNames.AutomationId] = "DaysList"; XamlComboBox CboMonths = new XamlComboBox(MS_XAML_DateTimeSelector_UIATest); CboMonths.SearchProperties[XamlComboBox.PropertyNames.AutomationId] = "MonthsList"; XamlComboBox CboYears = new XamlComboBox(MS_XAML_DateTimeSelector_UIATest); CboYears.SearchProperties[XamlComboBox.PropertyNames.AutomationId] = "YearsList"; CboYears.SelectedItem = "2010"; CboMonths.SelectedItem = "October"; CboDays.SelectedIndex = 22; msg += ".After:" + GetDateTime(MS_XAML_DateTimeSelector_UIATest); Assert.AreEqual("Before:19/March/2010/12/00/AM/.After:23/October/2010/12/00/AM/", msg); }
/// <summary> /// Verifies whether control is visible /// </summary> /// <param name="viewName"></param> /// <param name="controlName"></param> /// <param name="waitTime"></param> /// <param name="dynamicVariable"></param> /// <returns>true:control visible on screen;false:not visible</returns> public static bool VerifyControlVisible(string viewName, string controlName, int waitTime = WaitTime.DefaultWaitTime, string dynamicVariable = "") { Logger.InsertLogLine("Verify Control visible - Control: " + controlName + " in View : " + viewName); bool ControlVisible = false; Control control = PopulateControl(viewName, controlName, dynamicVariable); XamlButton xamlButton = new XamlButton(xamlAppWindow); foreach (string key in control.SearchProperties.Keys) { xamlButton.SearchProperties.Add(key, control.SearchProperties[key]); } xamlButton.WindowTitles.Add(windowName); xamlButton.WaitForControlExist(waitTime); Point point = new Point(); ControlVisible = xamlButton.TryGetClickablePoint(out point); return ControlVisible; }