diff --git a/TestingApplication/DatepickerWindow.xaml b/TestingApplication/DatepickerWindow.xaml
new file mode 100644
index 0000000..ae45ded
--- /dev/null
+++ b/TestingApplication/DatepickerWindow.xaml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/TestingApplication/DatepickerWindow.xaml.cs b/TestingApplication/DatepickerWindow.xaml.cs
new file mode 100644
index 0000000..4d2952d
--- /dev/null
+++ b/TestingApplication/DatepickerWindow.xaml.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace TestingApplication
+{
+ ///
+ /// Interaction logic for DatepickerWindow.xaml
+ ///
+ public partial class DatepickerWindow : Window
+ {
+ public DatepickerWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/TestingApplication/MainWindow.xaml b/TestingApplication/MainWindow.xaml
index a403835..a8bd896 100644
--- a/TestingApplication/MainWindow.xaml
+++ b/TestingApplication/MainWindow.xaml
@@ -13,11 +13,13 @@
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/TestingApplication/MainWindow.xaml.cs b/TestingApplication/MainWindow.xaml.cs
index b381365..516947a 100644
--- a/TestingApplication/MainWindow.xaml.cs
+++ b/TestingApplication/MainWindow.xaml.cs
@@ -37,7 +37,7 @@ private void Button_Click(object sender, RoutedEventArgs e)
btnwindow.Show();
}
- private void calendarButton_Click(object sender, RoutedEventArgs e)
+ private void CalendarButton_Click(object sender, RoutedEventArgs e)
{
CalendarWindow clndrwindow = new CalendarWindow();
clndrwindow.Owner = this;
@@ -46,7 +46,7 @@ private void calendarButton_Click(object sender, RoutedEventArgs e)
clndrwindow.Show();
}
- private void textBoxButton_Click(object sender, RoutedEventArgs e)
+ private void TextBoxButton_Click(object sender, RoutedEventArgs e)
{
TextWindow tw = new TextWindow();
tw.Owner = this;
@@ -54,7 +54,7 @@ private void textBoxButton_Click(object sender, RoutedEventArgs e)
tw.Show();
}
- private void comboBoxButton_Click(object sender, RoutedEventArgs e)
+ private void ComboBoxButton_Click(object sender, RoutedEventArgs e)
{
ComboBoxViewModel vm = new ComboBoxViewModel();
ComboBoxWindow cbw = new ComboBoxWindow(vm);
@@ -62,7 +62,7 @@ private void comboBoxButton_Click(object sender, RoutedEventArgs e)
cbw.Show();
}
- private void checkboxButton_Click(object sender, RoutedEventArgs e)
+ private void CheckboxButton_Click(object sender, RoutedEventArgs e)
{
CheckBoxViewModel viewModel=new CheckBoxViewModel();
CheckboxWindow checkboxWindow = new CheckboxWindow(viewModel);
@@ -72,7 +72,7 @@ private void checkboxButton_Click(object sender, RoutedEventArgs e)
checkboxWindow.Show();
}
- private void listboxButton_Click(object sender, RoutedEventArgs e)
+ private void ListboxButton_Click(object sender, RoutedEventArgs e)
{
ListboxWindow lstbxwindow = new ListboxWindow();
lstbxwindow.Owner = this;
@@ -80,5 +80,23 @@ private void listboxButton_Click(object sender, RoutedEventArgs e)
Application.Current.MainWindow = lstbxwindow;
lstbxwindow.Show();
}
+
+ private void DatepickerButton_Click(object sender, RoutedEventArgs e)
+ {
+ DatepickerWindow dtWindow = new DatepickerWindow();
+ dtWindow.Owner = this;
+ //Added for fixing blank window issue
+ Application.Current.MainWindow = dtWindow;
+ dtWindow.Show();
+ }
+
+ private void RadioButton_Click(object sender, RoutedEventArgs e)
+ {
+ RadioButtonWindow radioButtonWindow = new RadioButtonWindow();
+ radioButtonWindow.Owner = this;
+ //Added for fixing blank window issue
+ Application.Current.MainWindow = radioButtonWindow;
+ radioButtonWindow.Show();
+ }
}
}
\ No newline at end of file
diff --git a/TestingApplication/RadiobuttonWindow.xaml b/TestingApplication/RadiobuttonWindow.xaml
new file mode 100644
index 0000000..fe00e05
--- /dev/null
+++ b/TestingApplication/RadiobuttonWindow.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TestingApplication/RadiobuttonWindow.xaml.cs b/TestingApplication/RadiobuttonWindow.xaml.cs
new file mode 100644
index 0000000..273bbbf
--- /dev/null
+++ b/TestingApplication/RadiobuttonWindow.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using TestingApplication.ViewModel;
+
+namespace TestingApplication
+{
+ ///
+ /// Interaction logic for RadioButtonWindow.xaml
+ ///
+ public partial class RadioButtonWindow : Window
+ {
+ public RadioButtonWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Win11ThemeTest/ButtonTest.cs b/Win11ThemeTest/ButtonTest.cs
index 7d5dce2..18b9134 100644
--- a/Win11ThemeTest/ButtonTest.cs
+++ b/Win11ThemeTest/ButtonTest.cs
@@ -1,6 +1,7 @@
using FlaUI.Core;
using FlaUI.Core.AutomationElements;
using FlaUI.Core.Input;
+using FlaUI.Core.Tools;
using FlaUI.UIA3;
using NUnit.Framework.Internal;
using System.Configuration;
@@ -152,15 +153,16 @@ public void Button7_isDisabledClick()
[Test]
public void Button8_closeWindows()
{
- Assert.That(btnWindow, Is.Not.Null);
- btnWindow.Close();
- Wait.UntilInputIsProcessed();
- Assert.That(btnWindow.IsOffscreen);
- Wait.UntilInputIsProcessed();
- Assert.That(window, Is.Not.Null);
- window.Close();
- Assert.That(window.IsOffscreen);
+ if (app != null) {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
-
}
}
diff --git a/Win11ThemeTest/CalendarTest.cs b/Win11ThemeTest/CalendarTest.cs
index efb7e18..8fcfe34 100644
--- a/Win11ThemeTest/CalendarTest.cs
+++ b/Win11ThemeTest/CalendarTest.cs
@@ -6,6 +6,7 @@
using System.Globalization;
using Calendar = FlaUI.Core.AutomationElements.Calendar;
using System.Configuration;
+using FlaUI.Core.Tools;
namespace Win11ThemeTest
{
@@ -453,7 +454,7 @@ public void Calendars2_OnClickOfOtherMonthDate()
headerBtn = calendar.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
Assert.That(headerBtn, Is.Not.Null);
string headerName = headerBtn.Name;
- string[] hParts = headerName.Split(' ');
+ string[] hParts = headerName.Split(' ');
if (parts[1] == hParts[0])
{
dayBtn = dayButtons[44];
@@ -497,14 +498,17 @@ public void Calendars3_AddRangeToSelectionTest()
[Test]
public void Calendars4_closeWindows()
{
- Assert.That(calWindow, Is.Not.Null);
- calWindow.Focus();
- calWindow.Close();
- Assert.That(calWindow.IsOffscreen, Is.True);
- Wait.UntilInputIsProcessed();
- Assert.That(window, Is.Not.Null);
- window.Close();
- Assert.That(window.IsOffscreen, Is.True);
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
}
}
diff --git a/Win11ThemeTest/CheckBoxTest.cs b/Win11ThemeTest/CheckBoxTest.cs
deleted file mode 100644
index 83e4b3a..0000000
--- a/Win11ThemeTest/CheckBoxTest.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using FlaUI.Core;
-using FlaUI.Core.AutomationElements;
-using FlaUI.Core.Definitions;
-using FlaUI.UIA3;
-
-namespace Win11ThemeTest
-{
- public class cbTests
- {
- [SetUp]
- public void Setup()
- {
- }
-
- [Test]
- public void CheckBoxCheckedTest()
- {
- var app = FlaUI.Core.Application.Launch(@"..\\..\\..\\..\\Win11ThemeSampleApp\\bin\\x64\\Debug\\net9.0-windows\\win-x64\\Win11ThemeSampleApp.exe");
- using (var automation = new UIA3Automation())
- {
- var window = app.GetMainWindow(automation);
- var checkBox = window.FindFirstDescendant(cf => cf.ByName("Test Checkbox")).AsCheckBox();
- Assert.That(checkBox.ToggleState, Is.EqualTo(ToggleState.Off));
- checkBox.Toggle();
- Assert.That(checkBox.ToggleState, Is.EqualTo(ToggleState.On));
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Win11ThemeTest/CheckBoxTests.cs b/Win11ThemeTest/CheckBoxTests.cs
index e0384db..0e28b41 100644
--- a/Win11ThemeTest/CheckBoxTests.cs
+++ b/Win11ThemeTest/CheckBoxTests.cs
@@ -262,14 +262,17 @@ public void CheckboxThreeState9_is3stateCheckboxSelectOneOption()
[Test]
public void CloseWindows()
{
- Assert.That(checkboxWindow, Is.Not.Null);
- checkboxWindow.Close();
- Wait.UntilInputIsProcessed();
- Assert.That(checkboxWindow.IsOffscreen, Is.True);
- Wait.UntilInputIsProcessed();
- Assert.That(window, Is.Not.Null);
- window.Close();
- Assert.That(window.IsOffscreen, Is.True);
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
#endregion
}
diff --git a/Win11ThemeTest/ComboBoxTest.cs b/Win11ThemeTest/ComboBoxTest.cs
index 51d4d35..d0fb73c 100644
--- a/Win11ThemeTest/ComboBoxTest.cs
+++ b/Win11ThemeTest/ComboBoxTest.cs
@@ -9,30 +9,28 @@ namespace Win11ThemeTest
{
public class comboBoxTests
{
- private Application? app;
- private Window? mainWindow;
+ private readonly Application? app;
+ private readonly Window? mainWindow;
public Window? comboWindow;
- Button? comboBoxButton;
- ComboBox? comboBox;
- ComboBox? comboBoxEditable;
- ComboBox? comboBoxBind;
+ readonly Button? comboBoxButton;
+ readonly ComboBox? comboBox;
+ readonly ComboBox? comboBoxEditable;
+ readonly ComboBox? comboBoxBind;
public comboBoxTests()
{
try
{
var appPath = ConfigurationManager.AppSettings["Testpath"];
app = Application.Launch(appPath);
- using (var automation = new UIA3Automation())
- {
- mainWindow = app.GetMainWindow(automation);
- comboBoxButton = mainWindow.FindFirstDescendant(cf => cf.ByAutomationId("cmbBoxButton")).AsButton();
- Mouse.Click(comboBoxButton.GetClickablePoint());
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
- comboWindow = mainWindow.FindFirstDescendant(cf => cf.ByName("ComboBoxWindow")).AsWindow();
- comboBox = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxList")).AsComboBox();
- comboBoxEditable = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxEditable")).AsComboBox();
- comboBoxBind = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxBind")).AsComboBox();
- }
+ using var automation = new UIA3Automation();
+ mainWindow = app.GetMainWindow(automation);
+ comboBoxButton = mainWindow.FindFirstDescendant(cf => cf.ByAutomationId("cmbBoxButton")).AsButton();
+ Mouse.Click(comboBoxButton.GetClickablePoint());
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ comboWindow = mainWindow.FindFirstDescendant(cf => cf.ByName("ComboBoxWindow")).AsWindow();
+ comboBox = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxList")).AsComboBox();
+ comboBoxEditable = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxEditable")).AsComboBox();
+ comboBoxBind = comboWindow.FindFirstDescendant(cf => cf.ByAutomationId("comboBoxBind")).AsComboBox();
}
catch (Exception ex)
{
@@ -48,15 +46,13 @@ public comboBoxTests()
{
File.Create(filePath).Dispose();
}
- using (StreamWriter sw = File.AppendText(filePath))
- {
- string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
- sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
- sw.WriteLine("-------------------------------------------------------------------------------------");
- sw.WriteLine(error);
- sw.Flush();
- sw.Close();
- }
+ using StreamWriter sw = File.AppendText(filePath);
+ string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
+ sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
+ sw.WriteLine("-------------------------------------------------------------------------------------");
+ sw.WriteLine(error);
+ sw.Flush();
+ sw.Close();
}
else
{
@@ -66,59 +62,66 @@ public comboBoxTests()
}
[Test]
- public void comboBox_isAvailable()
+ public void ComboBox_isAvailable()
{
- Assert.IsNotNull(comboWindow);
- Assert.IsNotNull(comboBox);
- Assert.IsNotNull(comboBoxEditable);
- Assert.IsNotNull(comboBoxBind);
+ Assert.Multiple(() =>
+ {
+ Assert.That(comboWindow, Is.Not.Null);
+ Assert.That(comboBox, Is.Not.Null);
+ Assert.That(comboBoxEditable, Is.Not.Null);
+ Assert.That(comboBoxBind, Is.Not.Null);
+ });
}
[Test]
- public void comboBox_selectedDefaultItem()
+ public void ComboBox_selectedDefaultItem()
{
- Assert.IsNotNull(comboBox);
- Assert.That(comboBox.SelectedItem, Is.Not.Null);
+ Assert.That(comboBox, Is.Not.Null);
+ Assert.That(comboBox.SelectedItem, Is.Not.Null);
}
[Test]
- public void comboBox_isNull()
+ public void ComboBox_isNull()
{
- Assert.That(comboBox, Is.Not.Null);
+ Assert.That(comboBox, Is.Not.Null);
}
[Test]
- public void comboBox_isReadableEditable()
+ public void ComboBox_isReadableEditable()
{
- Assert.IsNotNull(comboBox);
- Assert.That(comboBox.IsReadOnly, Is.False);
- Assert.That(comboBox.IsEditable, Is.False);
- Assert.IsNotNull(comboBoxEditable);
+ Assert.That(comboBox, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(comboBox.IsReadOnly, Is.False);
+ Assert.That(comboBox.IsEditable, Is.False);
+
+ });
+ Assert.That(comboBoxEditable, Is.Not.Null);
Assert.That(comboBoxEditable.IsEditable, Is.True);
}
-
+
[Test]
- public void comboBox1_selectItem()
+ public void ComboBox1_selectItem()
{
- Assert.IsNotNull(comboBox);
+ Assert.That(comboBox, Is.Not.Null);
comboBox.Select("Red");
- Assert.That(comboBox.SelectedItem.Name, Is.EqualTo("Red"));
+ Assert.That(comboBox.SelectedItem.Name, Is.EqualTo("Red"));
}
//Check if the drop-down is open by clicking on both the drop-down & the drop-down Arrow.
- [Test]
- public void comboBox1_expandCollapse()
+ [Test]
+ public void ComboBox1_expandCollapse()
{
- Assert.IsNotNull(comboBox);
+ Assert.That(comboBox, Is.Not.Null);
comboBox.Expand();
Assert.That(comboBox.ExpandCollapseState, Is.EqualTo(ExpandCollapseState.Expanded));
comboBox.Collapse();
- Assert.That(comboBox.ExpandCollapseState, Is.EqualTo(ExpandCollapseState.Collapsed));
- }
+ Assert.That(comboBox.ExpandCollapseState, Is.EqualTo(ExpandCollapseState.Collapsed));
+ }
[Test]
- public void comboBox2_editableText()
- {
+ public void ComboBox2_editableText()
+ {
Assert.That(comboBoxEditable, Is.Not.Null);
Assert.That(comboBoxEditable.IsEditable, Is.True);
comboBoxEditable.EditableText = "10";
@@ -128,36 +131,39 @@ public void comboBox2_editableText()
//Check whether the dropdown is clickable or not.
[Test]
- public void comboBox3_mouseClick()
+ public void ComboBox3_mouseClick()
{
- Assert.IsNotNull(comboBox);
- Mouse.MoveTo(comboBox.GetClickablePoint());
- Mouse.Click();
+ Assert.That(comboBox, Is.Not.Null);
+ comboBox.Click();
Assert.That(comboBox.ExpandCollapseState, Is.EqualTo(ExpandCollapseState.Expanded));
comboBox.Collapse();
}
[Test]
- public void comboBox4_mouseSelectClick()
+ public void ComboBox4_mouseSelectClick()
{
- Assert.IsNotNull(comboBox);
+ Assert.That(comboBox, Is.Not.Null);
Mouse.MoveTo(comboBox.GetClickablePoint());
- Mouse.Click();
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ Mouse.Click();
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
comboBox.Items[3].Click();
- Assert.That(comboBox.SelectedItem.Name, Is.EqualTo("Yellow"));
+ Assert.That(comboBox.SelectedItem.Name, Is.EqualTo("Yellow"));
}
[Test]
- public void comboBox5_cleanUp()
+ public void ComboBox5_cleanUp()
{
- Assert.IsNotNull(comboWindow);
- comboWindow.Close();
- Wait.UntilInputIsProcessed();
- Assert.IsTrue(comboWindow.IsOffscreen);
- Assert.IsNotNull(mainWindow);
- mainWindow.Close();
- Assert.IsTrue(mainWindow.IsOffscreen);
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
}
}
diff --git a/Win11ThemeTest/DatepickerTest.cs b/Win11ThemeTest/DatepickerTest.cs
new file mode 100644
index 0000000..dacaa57
--- /dev/null
+++ b/Win11ThemeTest/DatepickerTest.cs
@@ -0,0 +1,554 @@
+using System;
+using System.Configuration;
+using System.Globalization;
+using FlaUI.Core;
+using FlaUI.Core.AutomationElements;
+using FlaUI.Core.Definitions;
+using FlaUI.Core.Input;
+using FlaUI.UIA3;
+
+
+namespace Win11ThemeTest
+{
+ public class DatePickerTest
+ {
+ private readonly Application? app;
+ private readonly Window? window;
+ public Window? dtPickerWindow;
+ readonly Button? testButton;
+ readonly DateTimePicker? datePicker;
+ readonly AutomationElement? calBtn;
+ AutomationElement? calWidget;
+ AutomationElement? headerBtn;
+ AutomationElement? prevBtn;
+ AutomationElement? nextBtn;
+ readonly TextBox? dtTextBox;
+ MenuItem? dtMenuCopy;
+ MenuItem? dtMenuCut;
+ MenuItem? dtMenuPaste;
+
+ public DatePickerTest()
+ {
+ try
+ {
+ var appPath = ConfigurationManager.AppSettings["Testpath"];
+ app = Application.Launch(appPath);
+ using var automation = new UIA3Automation();
+ window = app.GetMainWindow(automation);
+ testButton = window.FindFirstDescendant(cf => cf.ByAutomationId("datepickertestbtn")).AsButton();
+ Mouse.Click(testButton.GetClickablePoint());
+ Wait.UntilInputIsProcessed();
+ dtPickerWindow = window.FindFirstDescendant(cf => cf.ByName("DatepickerWindow")).AsWindow();
+ datePicker = dtPickerWindow.FindFirstDescendant(cf => cf.ByAutomationId("tstDatepicker")).AsDateTimePicker();
+ dtTextBox = datePicker.FindFirstChild(cf => cf.ByAutomationId("PART_TextBox")).AsTextBox();
+ calBtn = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ }
+ catch (Exception ex)
+ {
+ var filePath = ConfigurationManager.AppSettings["logpath"];
+ if (filePath != null)
+ {
+ if (!Directory.Exists(filePath))
+ {
+ Directory.CreateDirectory(filePath);
+ }
+ filePath = filePath + "log_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; //Text File Name
+ if (!File.Exists(filePath))
+ {
+ File.Create(filePath).Dispose();
+ }
+ using StreamWriter sw = File.AppendText(filePath);
+ string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
+ sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
+ sw.WriteLine("-------------------------------------------------------------------------------------");
+ sw.WriteLine(error);
+ sw.Flush();
+ sw.Close();
+ }
+ else
+ {
+ throw new ArgumentNullException();
+ }
+
+ }
+
+ }
+
+ //test if date picker is available in window
+ [Test]
+ public void DatePicker1_isAvailable()
+ {
+ Assert.Multiple(() =>
+ {
+ Assert.That(dtPickerWindow, Is.Not.Null);
+ Assert.That(datePicker, Is.Not.Null);
+ });
+ }
+
+ //test if date input is the selected date and the date format is dd MMMM yyyy
+ [Test]
+ public void DatePicker2_SelectDate()
+ {
+ Assert.That(datePicker, Is.Not.Null);
+ DateTime thisDay = DateTime.Today;
+ datePicker.SelectedDate = thisDay;
+ DateTime dt_selectedDate = DateTime.Parse(datePicker.Patterns.Value.Pattern.Value);
+ Assert.That(dt_selectedDate, Is.EqualTo(thisDay));
+ Wait.UntilInputIsProcessed();
+ Assert.That(dtTextBox, Is.Not.Null);
+ DateTime txtDate = DateTime.Parse(dtTextBox.Text);
+ Assert.That(txtDate.ToString("dd MMMM yyyy"), Is.EqualTo(thisDay.ToString("dd MMMM yyyy")));
+ }
+
+ //test if calendar widget appears on click of calendar icon
+ [Test]
+ public void DatePicker3_isCalendarClickable()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ Assert.That(calWidget, Is.Not.Null);
+ calBtn.Click();
+ }
+
+ #region calendarScenarios
+ //test if calendar widget has current month
+ [Test]
+ public void DatePicker4_calendarMonth()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ DateTime thisDay = DateTime.Today;
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ string headerName = headerBtn.Name;
+ string Month = thisDay.ToString("MMMM");
+ string[] yearMonth = headerName.Split(' ');
+ Assert.That(yearMonth[0], Is.EqualTo(Month));
+ calBtn.Click();
+ }
+
+ //test for click previous month button
+ [Test]
+ public void DatePicker5_CalendarClickPrevMonth()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ string oldHeaderName = headerBtn.Name;
+ prevBtn = calWidget.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ prevBtn.Click();
+ string headerName = headerBtn.Name;
+ string[] oldYearMonth = oldHeaderName.Split(' ');
+ int currentMonth = DateTime.ParseExact(oldYearMonth[0], "MMMM", CultureInfo.CurrentCulture).Month;
+ DateTime currentDate = new DateTime(Convert.ToInt32(oldYearMonth[1]), currentMonth, 1).AddMonths(-1);
+ int year = currentDate.Year;
+ string Month = currentDate.ToString("MMMM");
+ string[] yearMonth = headerName.Split(' ');
+ Assert.Multiple(() =>
+ {
+ Assert.That(yearMonth[0], Is.EqualTo(Month));
+ Assert.That(Convert.ToInt32(yearMonth[1]), Is.EqualTo(year));
+ });
+ calBtn.Click();
+ }
+
+ [Test]
+ //test for click next month button
+ public void DatePicker6_CalendarClickNextMonth()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ string oldHeaderName = headerBtn.Name;
+ nextBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_NextButton"));
+ nextBtn.Click();
+ string headerName = headerBtn.Name;
+ string[] oldYearMonth = oldHeaderName.Split(' ');
+ int currentMonth = DateTime.ParseExact(oldYearMonth[0], "MMMM", CultureInfo.CurrentCulture).Month;
+ DateTime currentDate = new DateTime(Convert.ToInt32(oldYearMonth[1]), currentMonth, 1).AddMonths(1);
+ int year = currentDate.Year;
+ string Month = currentDate.ToString("MMMM");
+ string[] yearMonth = headerName.Split(' ');
+ Assert.Multiple(() =>
+ {
+ Assert.That(yearMonth[0], Is.EqualTo(Month));
+ Assert.That(Convert.ToInt32(yearMonth[1]), Is.EqualTo(year));
+ });
+
+ //reset to current month
+ prevBtn = calWidget.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ prevBtn.Click();
+ calBtn.Click();
+ }
+
+ //test for click Month-year button
+ [Test]
+ public void DatePicker7_CalendarClickMonthYear()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ headerBtn.Click();
+ Wait.UntilInputIsProcessed();
+ string headerName = headerBtn.Name;
+ DateTime currentMonth = DateTime.Today;
+ int year = currentMonth.Year;
+ Assert.That(Convert.ToInt32(headerName), Is.EqualTo(year));
+ calBtn.Click();
+ }
+
+ //test for click prev year button
+ [Test]
+ public void DatePicker8_CalendarClickPrevYear()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ prevBtn = calWidget.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ headerBtn.Click();
+ prevBtn.Click();
+ string headerName = headerBtn.Name;
+ DateTime prevYear = DateTime.Today.AddYears(-1);
+ int year = prevYear.Year;
+ Assert.That(Convert.ToInt32(headerName), Is.EqualTo(year));
+ //reset
+ nextBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_NextButton"));
+ nextBtn.Click();
+ calBtn.Click();
+ }
+
+ //test for click next year button
+ [Test]
+ public void DatePicker9_isCalendarClickNextYear()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ nextBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_NextButton"));
+ headerBtn.Click();
+ Wait.UntilInputIsProcessed();
+ nextBtn.Click();
+ Wait.UntilInputIsProcessed();
+ string headerName = headerBtn.Name;
+ DateTime nextYear = DateTime.Today.AddYears(1);
+ int year = nextYear.Year;
+ Assert.That(Convert.ToInt32(headerName), Is.EqualTo(year));
+ //reset
+ prevBtn = calWidget.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ prevBtn.Click();
+ Wait.UntilInputIsProcessed();
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ }
+
+ //test for click year button
+ [Test]
+ public void DatePickers1_CalendarClickYear()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ headerBtn.Click();
+ headerBtn.Click();
+ string headerName = headerBtn.Name;
+ DateTime currentMonth = DateTime.Today;
+ int year = currentMonth.Year;
+ string[] parts = headerName.Split('-');
+ int yearLow = Convert.ToInt32(parts[0]);
+ int yearHigh = Convert.ToInt32(parts[1]);
+ Assert.That(year, Is.GreaterThan(yearLow));
+ Assert.That(year, Is.LessThan(yearHigh));
+ calBtn.Click();
+ }
+
+ //test for click previous year range button
+ [Test]
+ public void DatePickers2_CalendarClickPrevYearRange()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ headerBtn.Click();
+ Wait.UntilInputIsProcessed();
+ headerBtn.Click();
+ Wait.UntilInputIsProcessed();
+ string headerName = headerBtn.Name;
+ prevBtn = calWidget.FindFirstChild(cf => cf.ByControlType(ControlType.Button));
+ prevBtn.Click();
+ Wait.UntilInputIsProcessed();
+ string prevHeaderName = headerBtn.Name;
+ DateTime currentMonth = DateTime.Today;
+ int year = currentMonth.Year;
+ string[] parts = headerName.Split('-');
+ int yearLow = Convert.ToInt32(parts[0]);
+ int yearHigh = Convert.ToInt32(parts[1]);
+ string[] prevParts = prevHeaderName.Split('-');
+ int prevYearLow = Convert.ToInt32(prevParts[0]);
+ int prevYearHigh = Convert.ToInt32(prevParts[1]);
+ int lowDiff = yearLow - prevYearLow;
+ int highDiff = yearHigh - prevYearHigh;
+ Assert.Multiple(() =>
+ {
+ Assert.That(lowDiff, Is.EqualTo(10));
+ Assert.That(highDiff, Is.EqualTo(10));
+ });
+ calBtn.Click();
+ }
+
+ //test for click next year range button
+ [Test]
+ public void DatePickers3_CalendarClickNextYearRange()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ calBtn.Click();
+ Assert.That(datePicker, Is.Not.Null);
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Assert.That(calWidget, Is.Not.Null);
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ headerBtn.Click();
+ headerBtn.Click();
+ string headerName = headerBtn.Name;
+ nextBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_NextButton"));
+ nextBtn.Click();
+ string nextHeaderName = headerBtn.Name;
+ DateTime currentMonth = DateTime.Today;
+ int year = currentMonth.Year;
+ string[] parts = headerName.Split('-');
+ int yearLow = Convert.ToInt32(parts[0]);
+ int yearHigh = Convert.ToInt32(parts[1]);
+ string[] nextParts = nextHeaderName.Split('-');
+ int nextYearLow = Convert.ToInt32(nextParts[0]);
+ int nextYearHigh = Convert.ToInt32(nextParts[1]);
+ int lowDiff = nextYearLow - yearLow;
+ int highDiff = nextYearHigh - yearHigh;
+ Assert.Multiple(() =>
+ {
+ Assert.That(lowDiff, Is.EqualTo(10));
+ Assert.That(highDiff, Is.EqualTo(10));
+ });
+ calBtn.Click();
+ }
+
+ //test click on other month dates loads that month
+ [Test]
+ public void DatePickers4_OnClickOfOtherMonthDate()
+ {
+ Assert.That(calBtn, Is.Not.Null);
+ DateTime thisDay = DateTime.Today;
+ Assert.That(datePicker, Is.Not.Null);
+ datePicker.SelectedDate = thisDay;
+ Wait.UntilInputIsProcessed();
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ if (calWidget == null)
+ {
+ calBtn.Click();
+ calWidget = datePicker.FindFirstChild(cf => cf.ByControlType(ControlType.Calendar));
+ }
+ Wait.UntilInputIsProcessed();
+ AutomationElement[] dayButtons = calWidget.FindAllChildren(cf => cf.ByControlType(ControlType.Button));
+ AutomationElement dayBtn = dayButtons[3];
+ string dayBtnString = dayButtons[3].Name;
+ string[] parts = dayBtnString.Split(' ');
+ headerBtn = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ string headerName = headerBtn.Name;
+ string[] hParts = headerName.Split(' ');
+ if (parts[1] == hParts[0])
+ {
+ dayBtn = dayButtons[44];
+ dayBtnString = dayButtons[44].Name;
+ parts = dayBtnString.Split(' ');
+ }
+ if (parts[1] != hParts[0])
+ {
+ dayBtn.Click();
+ calBtn.Click();
+ Wait.UntilInputIsProcessed();
+ }
+ DateTime dateTime = DateTime.Parse(dayBtnString);
+ dayBtnString = dateTime.ToString("MMMM yyyy");
+ AutomationElement headerBtnNew = calWidget.FindFirstChild(cf => cf.ByAutomationId("PART_HeaderButton"));
+ Assert.That(headerBtnNew.Name, Is.EqualTo(dayBtnString));
+ calBtn.Click();
+ }
+ #endregion
+
+ //test keyboard input for date- valid date
+ [Test]
+ public void DatePickers5_ValidKeyboardInput()
+ {
+ Assert.That(datePicker, Is.Not.Null);
+ datePicker.Focus();
+ DateTime sDate = new DateTime(2024, 09, 21);
+ Keyboard.Type("2024/09/21");
+ Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.ENTER);
+ Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.ENTER);
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
+ Assert.That(dtTextBox, Is.Not.Null);
+ DateTime txtDate = DateTime.Parse(dtTextBox.Text);
+ Assert.That(txtDate.ToString("dd MMMM yyyy"), Is.EqualTo(sDate.ToString("dd MMMM yyyy")));
+ }
+
+ //test keyboard input for date- invalid date
+ [Test]
+ public void DatePickers6_InvalidKeyboardInput()
+ {
+ Assert.That(datePicker, Is.Not.Null);
+ string beforeDate = datePicker.Patterns.Value.Pattern.Value;
+ datePicker.Focus();
+ Wait.UntilInputIsProcessed();
+ Keyboard.Type("2024/20/21");
+ Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.ENTER);
+ Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.ENTER);
+ Wait.UntilInputIsProcessed();
+ string afterDate = datePicker.Patterns.Value.Pattern.Value;
+ Assert.That(beforeDate, Is.EqualTo(afterDate));
+ }
+
+ //right click on date picker textbox-menu items copy, cut and paste
+ [Test]
+ public void DatePickers7_RightClick()
+ {
+ Assert.That(dtTextBox, Is.Not.Null);
+ dtTextBox.Focus();
+ dtTextBox.RightClick();
+ Assert.That(dtPickerWindow, Is.Not.Null);
+ dtMenuCopy = dtPickerWindow.FindFirstDescendant(cf => cf.ByName("Copy")).AsMenuItem();
+ dtMenuPaste = dtPickerWindow.FindFirstDescendant(cf => cf.ByName("Paste")).AsMenuItem();
+ dtMenuCut = dtPickerWindow.FindFirstDescendant(cf => cf.ByName("Cut")).AsMenuItem();
+ Assert.Multiple(() =>
+ {
+ Assert.That(dtMenuCopy, Is.Not.Null);
+ Assert.That(dtMenuPaste, Is.Not.Null);
+ Assert.That(dtMenuCut, Is.Not.Null);
+ });
+ Mouse.Click();
+ }
+
+ //test for copy and paste menu action items
+ [Test]
+ public void DatePickers8_datePickerCopyPaste()
+ {
+ Assert.That(datePicker, Is.Not.Null);
+ DateTime thisDay = DateTime.Today;
+ datePicker.SelectedDate = thisDay;
+ Assert.That(dtTextBox, Is.Not.Null);
+ string beforeCopy = dtTextBox.Text;
+ Console.WriteLine(beforeCopy);
+ dtTextBox.RightClick();
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
+ Assert.That(dtPickerWindow, Is.Not.Null);
+ var copyText = dtPickerWindow.FindFirstDescendant(cf => cf.ByName("Copy")).AsMenuItem();
+ Assert.That(copyText, Is.Not.Null);
+ var pattern = dtTextBox.Patterns.Text.Pattern.DocumentRange;
+ pattern.Select();
+ Mouse.MoveTo(copyText.GetClickablePoint());
+ copyText.Click();
+ copyText.Click();
+ Wait.UntilInputIsProcessed();
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
+ dtTextBox.Text = null;
+ dtTextBox.RightClick();
+ var pasteText = dtPickerWindow.FindFirstDescendant(cf => cf.ByName("Paste")).AsMenuItem();
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
+ Assert.That(pasteText, Is.Not.Null);
+ pasteText.Click();
+ Wait.UntilInputIsProcessed();
+ Assert.IsNotNull(dtTextBox.Text);
+ string afterCopy = dtTextBox.Text;
+ Assert.That(beforeCopy, Is.EqualTo(afterCopy));
+ }
+
+ [Test]
+ public void DatePickers9_closeWindows()
+ {
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
+ }
+ }
+}
diff --git a/Win11ThemeTest/ListBoxTest.cs b/Win11ThemeTest/ListBoxTest.cs
index 4f67179..5092529 100644
--- a/Win11ThemeTest/ListBoxTest.cs
+++ b/Win11ThemeTest/ListBoxTest.cs
@@ -171,14 +171,17 @@ public void ListBoxs1_verticalScroll()
[Test]
public void ListBoxs2_closeWindows()
{
- Assert.That(listBoxWindow, Is.Not.Null);
- listBoxWindow.Close();
- Wait.UntilInputIsProcessed();
- Assert.That(window, Is.Not.Null);
- Wait.UntilInputIsProcessed();
- Assert.That(listBoxWindow.IsOffscreen, Is.True);
- window.Close();
- Assert.That(window.IsOffscreen, Is.True);
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
}
diff --git a/Win11ThemeTest/RadioButtonTest.cs b/Win11ThemeTest/RadioButtonTest.cs
index a54116e..1a970aa 100644
--- a/Win11ThemeTest/RadioButtonTest.cs
+++ b/Win11ThemeTest/RadioButtonTest.cs
@@ -3,101 +3,214 @@
using FlaUI.Core.Definitions;
using FlaUI.Core.Input;
using FlaUI.UIA3;
-using System.Windows;
-using System.Windows.Input;
-using System.Xml.Linq;
-using System.Text;
+using System.Configuration;
+
namespace Win11ThemeTest
{
[TestFixture]
- public class rbTests
+ public class radioButtonTests
{
- private Application app;
- private Window window;
- RadioButton radioButton1;
- RadioButton radioButton2;
- RadioButton radioButton3;
- RadioButton radioButton4;
- RadioButton radioButton5;
- RadioButton radioButton6;
-
- public rbTests()
- {
- app = Application.Launch(@"..\\..\\..\\..\\Win11ThemeSampleApp\\bin\\x64\\Debug\\net9.0-windows\\win-x64\\Win11ThemeSampleApp.exe");
+ private readonly Application? app;
+ private readonly Window? window;
+ public Button? testButton;
+ public Window? radioBtnWindow;
+ readonly RadioButton? optionA;
+ readonly RadioButton? optionB;
+ readonly RadioButton? optionC;
+ readonly RadioButton? optionD;
- using (var automation = new UIA3Automation())
+ readonly RadioButton? radioButton1;
+ readonly RadioButton? radioButton2;
+ readonly RadioButton? radioButton3;
+ readonly RadioButton? radioButton4;
+ readonly RadioButton? radioButton5;
+ readonly RadioButton? radioButton6;
+ public radioButtonTests()
+ {
+ try
{
+ var appPath = ConfigurationManager.AppSettings["Testpath"];
+ app = Application.Launch(appPath);
+ using var automation = new UIA3Automation();
window = app.GetMainWindow(automation);
+ testButton = window.FindFirstDescendant(cf => cf.ByAutomationId("radioButton")).AsButton();
+ Mouse.Click(testButton.GetClickablePoint());
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(2000));
+ radioBtnWindow = window.FindFirstDescendant(cf => cf.ByName("RadioButtonWindow")).AsWindow();
+ optionA = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("Option A")).AsRadioButton();
+ optionB = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("Option B")).AsRadioButton();
+ optionC = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("Option C")).AsRadioButton();
+ optionD = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("Option D")).AsRadioButton();
+
+ radioButton1 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton1")).AsRadioButton();
+ radioButton2 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton2")).AsRadioButton();
+ radioButton3 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton3")).AsRadioButton();
+ radioButton4 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton4")).AsRadioButton();
+ radioButton5 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton5")).AsRadioButton();
+ radioButton6 = radioBtnWindow.FindFirstDescendant(cf => cf.ByName("RadioButton6")).AsRadioButton();
}
+ catch (Exception ex)
+ {
+ var filePath = ConfigurationManager.AppSettings["logpath"];
+ if (filePath != null)
+ {
+ if (!Directory.Exists(filePath))
+ {
+ Directory.CreateDirectory(filePath);
+ }
+ filePath = filePath + "log_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; //Text File Name
+ if (!File.Exists(filePath))
+ {
+ File.Create(filePath).Dispose();
+ }
+ using StreamWriter sw = File.AppendText(filePath);
+ string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
+ sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
+ sw.WriteLine("-------------------------------------------------------------------------------------");
+ sw.WriteLine(error);
+ sw.Flush();
+ sw.Close();
+ }
+ else
+ {
+ throw new ArgumentNullException();
+ }
- radioButton1 = window.FindFirstDescendant(cf => cf.ByName("RadioButton1")).AsRadioButton();
- radioButton2 = window.FindFirstDescendant(cf => cf.ByName("RadioButton2")).AsRadioButton();
- radioButton3 = window.FindFirstDescendant(cf => cf.ByName("RadioButton3")).AsRadioButton();
- radioButton4 = window.FindFirstDescendant(cf => cf.ByName("RadioButton4")).AsRadioButton();
- radioButton5 = window.FindFirstDescendant(cf => cf.ByName("RadioButton5")).AsRadioButton();
- radioButton6 = window.FindFirstDescendant(cf => cf.ByName("RadioButton6")).AsRadioButton();
+ }
}
+ //Check if the radio buttons are initially unselected.
[Test]
- public void RadioButtonTest_1()
+ public void RadioButton1_isUncheck()
{
- // Checking if a radio button in both the groups are clickable
- Assert.That(radioButton1.IsChecked, Is.False);
- Assert.That(radioButton2.IsChecked, Is.False);
- Assert.That(radioButton3.IsChecked, Is.False);
- Assert.That(radioButton4.IsChecked, Is.False);
- Assert.That(radioButton5.IsChecked, Is.False);
- Assert.That(radioButton6.IsChecked, Is.False);
+ Assert.That(optionA, Is.Not.Null);
+ Assert.That(optionA.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionB, Is.Not.Null);
+ Assert.That(optionB.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionC, Is.Not.Null);
+ Assert.That(optionC.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionD, Is.Not.Null);
+ Assert.That(optionD.IsChecked, Is.False);
+ }
- Mouse.Click(radioButton1.GetClickablePoint());
- Mouse.Click(radioButton5.GetClickablePoint());
+ //Validate that clicking on the label associated with a radio button selects the button.
+ [Test]
+ public void RadioButton2_labelCheck()
+ {
+ Assert.That(optionA, Is.Not.Null);
+ Mouse.Click(optionA.GetClickablePoint());
+ Assert.That(optionA.IsChecked, Is.True);
+ }
- Assert.That(radioButton1.IsChecked, Is.True);
- Assert.That(radioButton2.IsChecked, Is.False);
- Assert.That(radioButton3.IsChecked, Is.False);
- Assert.That(radioButton4.IsChecked, Is.False);
- Assert.That(radioButton5.IsChecked, Is.True);
- Assert.That(radioButton6.IsChecked, Is.False);
+ // Re-checking on a checked radio button does not affect it's checked state
+ [Test]
+ public void RadioButton3_state()
+ {
+ Assert.That(optionA, Is.Not.Null);
+ Assert.That(optionA.IsChecked, Is.True);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionB, Is.Not.Null);
+ Assert.That(optionB.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionC, Is.Not.Null);
+ Assert.That(optionC.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionD, Is.Not.Null);
+ Assert.That(optionD.IsChecked, Is.False);
+
+ optionD.Click();
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(optionA.IsChecked, Is.False);
+ Assert.That(optionB.IsChecked, Is.False);
+ Assert.That(optionC.IsChecked, Is.False);
+ Assert.That(optionD.IsChecked, Is.True);
+ });
}
+ //Verify that only one radio button can be selected at a time.
+ //Confirm that selecting one radio button deselects any previously selected option.
[Test]
- public void RadioButtonTest_2()
+ public void RadioButton4_selection()
{
- // Re-checking on a checked radio button does not affect it's checked state
- Assert.That(radioButton1.IsChecked, Is.True);
- Assert.That(radioButton5.IsChecked, Is.True);
+ Assert.That(optionA, Is.Not.Null);
+ Mouse.Click(optionA.GetClickablePoint());
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionA.IsChecked, Is.True);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionB, Is.Not.Null);
+ Assert.That(optionB.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionC, Is.Not.Null);
+ Assert.That(optionC.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(optionD, Is.Not.Null);
+ Assert.That(optionD.IsChecked, Is.False);
- Mouse.Click(radioButton1.GetClickablePoint());
- Mouse.Click(radioButton5.GetClickablePoint());
-
- Assert.That(radioButton1.IsChecked, Is.True);
- Assert.That(radioButton5.IsChecked, Is.True);
+ //select option B and make sure option A gets deselected
+ Mouse.Click(optionB.GetClickablePoint());
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(optionA.IsChecked, Is.False);
+ Assert.That(optionB.IsChecked, Is.True);
+ Assert.That(optionC.IsChecked, Is.False);
+ Assert.That(optionD.IsChecked, Is.False);
+ });
}
+ // Checking if a radio button in both the groups are clickable
[Test]
- public void RadioButtonTest_3()
+ public void RadioButton5_groupCheck()
{
- // Checking a different radio button
- Assert.That(radioButton1.IsChecked, Is.True);
+ Assert.That(radioButton1, Is.Not.Null);
+ Assert.That(radioButton1.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton2, Is.Not.Null);
Assert.That(radioButton2.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton3, Is.Not.Null);
Assert.That(radioButton3.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton4, Is.Not.Null);
+ Assert.That(radioButton4.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton5, Is.Not.Null);
+ Assert.That(radioButton5.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton6, Is.Not.Null);
+ Assert.That(radioButton6.IsChecked, Is.False);
+
- Mouse.Click(radioButton2.GetClickablePoint());
+ radioButton1.Click();
+ radioButton5.Click();
- Assert.That(radioButton1.IsChecked, Is.False);
- Assert.That(radioButton2.IsChecked, Is.True);
- Assert.That(radioButton3.IsChecked, Is.False);
+ Assert.Multiple(() =>
+ {
+ Assert.That(radioButton1.IsChecked, Is.True);
+ Assert.That(radioButton2.IsChecked, Is.False);
+ Assert.That(radioButton3.IsChecked, Is.False);
+ Assert.That(radioButton4.IsChecked, Is.False);
+ Assert.That(radioButton5.IsChecked, Is.True);
+ Assert.That(radioButton6.IsChecked, Is.False);
+ });
}
+ // Checking or Selecting a disabled radio button
[Test]
- public void RadioButtonTest_4()
+ public void RadioButtonTest6_KeyboardSelect()
{
- // Checking or Selecting a disabled radio button
+ Assert.That(radioButton3, Is.Not.Null);
Assert.That(radioButton3.IsChecked, Is.False);
Mouse.Click(radioButton3.GetClickablePoint());
Assert.That(radioButton3.IsChecked, Is.False);
-
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton1, Is.Not.Null);
radioButton1.Focus();
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.TAB);
@@ -105,58 +218,115 @@ public void RadioButtonTest_4()
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.TAB);
Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.TAB);
+ // Get the current mouse position
+ //var mousePosition = Mouse.Position;
+
+ // Output the mouse position
+ // Console.WriteLine($"Mouse Position: X = {mousePosition.X}, Y = {mousePosition.Y}");
+
+ // Get the element at the mouse position
+ using var automation2 = new UIA3Automation();
- /**
- *
- *
- * TODO: Implement Focus Testing
- * Verify that the currently focused radiobutton is not radiobutton3
- *
- */
-
+ //var automation = new FlaUI.UIA3.Core.AutomationElement.Automation();
+ //var element = automation2.FromPoint(mousePosition);
+ var element = automation2.FocusedElement();
+ // Check if an element is found at the mouse position
+ if (element != null)
+ {
+ // Get the element's name (or any other property) to identify the focused element
+ var elementName = element.Name;
+
+ // Output the focused element's name
+ Console.WriteLine($"Focused Element: {elementName}");
+ Assert.That(radioButton4, Is.Not.Null);
+ Assert.That(radioButton4.Name, Is.EqualTo(elementName));
+
+ }
}
+ // Test to confirm click in one group does not affect checked radio button in another group
[Test]
- public void RadioButtonTest_5()
+ public void RadioButtonTest7_ClickGroupButton()
{
- // Test to confirm click in one group does not affect checked radio button in another group
+ //Group 1 radio button
+ Assert.That(radioButton2, Is.Not.Null);
+ radioButton2.Click();
Assert.That(radioButton2.IsChecked, Is.True);
- Mouse.Click(radioButton4.GetClickablePoint());
- Mouse.Click(radioButton5.GetClickablePoint());
- Mouse.Click(radioButton6.GetClickablePoint());
+ //Group 2 radio button
+ Assert.That(radioButton5, Is.Not.Null);
+ radioButton5.Click();
+ Assert.That(radioButton5.IsChecked, Is.True);
+ Assert.That(radioButton1, Is.Not.Null);
+ Assert.That(radioButton1.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
Assert.That(radioButton2.IsChecked, Is.True);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton3, Is.Not.Null);
+ Assert.That(radioButton3.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton4, Is.Not.Null);
+ Assert.That(radioButton4.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton5.IsChecked, Is.True);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton6, Is.Not.Null);
+ Assert.That(radioButton6.IsChecked, Is.False);
+
}
+ // Test to confirm radio buttons can be checked using space bar
[Test]
- public void RadioButtonTest_6()
+ public void RadioButtonTest8_SelectWithSapceKey()
{
- // Test to confirm radio buttons can be checked using space bar
- Assert.That(radioButton1.IsChecked, Is.False);
- Assert.That(radioButton2.IsChecked, Is.True);
-
+ Assert.That(radioButton2, Is.Not.Null);
+ radioButton2.Click();
+ Assert.That(radioButton1, Is.Not.Null);
+ Assert.Multiple(() =>
+ {
+ Assert.That(radioButton1.IsChecked, Is.False);
+ Assert.That(radioButton2.IsChecked, Is.True);
+ });
radioButton2.Focus();
Keyboard.TypeSimultaneously(FlaUI.Core.WindowsAPI.VirtualKeyShort.SHIFT, FlaUI.Core.WindowsAPI.VirtualKeyShort.TAB);
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.SPACE);
Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.SPACE);
-
- Assert.That(radioButton1.IsChecked, Is.True);
- Assert.That(radioButton2.IsChecked, Is.False);
+ Wait.UntilInputIsProcessed();
+ Assert.Multiple(() =>
+ {
+ Assert.That(radioButton1.IsChecked, Is.True);
+ Assert.That(radioButton2.IsChecked, Is.False);
+ });
}
+ // Test to confirm correct initialization from code behind
[Test]
- public void RadioButtonTest_7()
+ public void RadioButtonTest9_testInitialization()
{
- // Test to confirm correct initialization from code behind
+ Assert.That(radioButton4, Is.Not.Null);
Assert.That(radioButton4.IsEnabled, Is.True);
+ Wait.UntilInputIsProcessed();
+ Assert.That(radioButton5, Is.Not.Null);
Assert.That(radioButton5.IsEnabled, Is.True);
- Assert.That(radioButton6.IsEnabled, Is.False);
+ }
- // Close the window
- window.Close();
+ [Test]
+ public void RadioButtonTest91_cleanUp()
+ {
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
}
}
diff --git a/Win11ThemeTest/TextBoxTest.cs b/Win11ThemeTest/TextBoxTest.cs
index 1da790d..eac1c18 100644
--- a/Win11ThemeTest/TextBoxTest.cs
+++ b/Win11ThemeTest/TextBoxTest.cs
@@ -11,15 +11,15 @@ namespace Win11ThemeTest
[TestFixture]
public class textBoxTests
{
- private Application? app;
- private Window? mainWindow;
+ private readonly Application? app;
+ private readonly Window? mainWindow;
public Window? textWindow;
- TextBox? textBox;
- TextBox? disabledTextBox;
- TextBox? multiLineTextBox;
- Button? txtButton;
- UIA3Automation automation = new UIA3Automation();
-
+ readonly TextBox? textBox;
+ readonly TextBox? disabledTextBox;
+ readonly TextBox? multiLineTextBox;
+ readonly Button? txtButton;
+ readonly UIA3Automation automation = new();
+
public textBoxTests()
{
try
@@ -49,48 +49,49 @@ public textBoxTests()
{
File.Create(filePath).Dispose();
}
- using (StreamWriter sw = File.AppendText(filePath))
- {
- string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
- sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
- sw.WriteLine("-------------------------------------------------------------------------------------");
- sw.WriteLine(error);
- sw.Flush();
- sw.Close();
- }
+ using StreamWriter sw = File.AppendText(filePath);
+ string error = "Log Written Date:" + " " + DateTime.Now.ToString() + "\nError Message:" + " " + ex.Message.ToString();
+ sw.WriteLine("-----------Exception Details on " + " " + DateTime.Now.ToString() + "-----------------");
+ sw.WriteLine("-------------------------------------------------------------------------------------");
+ sw.WriteLine(error);
+ sw.Flush();
+ sw.Close();
}
else
{
throw new ArgumentNullException();
}
- }
+ }
}
[Test]
- public void textbox_findTextBox()
+ public void Textbox_findTextBox()
{
- Assert.IsNotNull(textWindow);
- Assert.IsNotNull(textBox);
+ Assert.Multiple(() =>
+ {
+ Assert.That(textWindow, Is.Not.Null);
+ Assert.That(textBox, Is.Not.Null);
+ });
}
#region FunctionalTests
[Test]
- public void textBox_enterText()
+ public void TextBox_enterText()
{
- Assert.IsNotNull(textBox);
- textBox.Enter("Hello World!");
+ Assert.That(textBox, Is.Not.Null);
+ textBox.Enter("Hello World!");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
Assert.That(textBox.Text, Is.EqualTo("Hello World!"));
- }
+ }
//Verify that the text box accepts alphanumeric characters.
[Test]
- public void textBox_enterAlphaNumericText()
+ public void TextBox_enterAlphaNumericText()
{
var expectedText = "/\\d.*[a-zA-Z]|[a-zA-Z].*\\d/";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("/\\d.*[a-zA-Z]|[a-zA-Z].*\\d/");
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
if (textBox.Text != expectedText)
{
Assert.Fail("Result : {0} and Expected {1} ", textBox.Text, expectedText);
@@ -103,12 +104,12 @@ public void textBox_enterAlphaNumericText()
//Verify that the text box accepts special characters.
[Test]
- public void textBox_enterSpecialCharText()
+ public void TextBox_enterSpecialCharText()
{
var expectedText = "@#$%^&*";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("@#$%^&*");
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
if (textBox.Text != "@#$%^&*")
{
Assert.Fail("Result : {0} and Expected {1} ", textBox.Text, expectedText);
@@ -121,12 +122,12 @@ public void textBox_enterSpecialCharText()
//Check if the text box can handle empty input.
[Test]
- public void textBox_enterEmptyText()
+ public void TextBox_enterEmptyText()
{
var emptyText = string.Empty;
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter(emptyText);
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
if (textBox.Text != string.Empty)
{
Assert.Fail("Result : {0} and Expected {1} ", textBox.Text, string.Empty);
@@ -135,16 +136,16 @@ public void textBox_enterEmptyText()
{
Assert.Pass("Result : {0} and Expected {1} ", textBox.Text, string.Empty);
}
- }
+ }
//Test input validation for correct data formats (e.g., email validation).
[Test]
- public void textBox_enterEmailIdText()
+ public void TextBox_enterEmailIdText()
{
var expectedText = "ram.shyam1234@yahoo.com";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("ram.shyam1234@yahoo.com");
- Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
+ Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
if (textBox.Text != expectedText)
{
Assert.Fail("Result : {0} and Expected {1} ", textBox.Text, expectedText);
@@ -156,23 +157,23 @@ public void textBox_enterEmailIdText()
}
[Test]
- public void textBox_multiLineTextbox()
+ public void TextBox_multiLineTextbox()
{
- string testDescription = "New line text.\n Line1\nLine2 \nLine3";
- Assert.IsNotNull(multiLineTextBox);
- multiLineTextBox.Enter(testDescription);
+ string testDescription = "New line text.\nLine1\nLine2 \nLine3";
+ Assert.That(multiLineTextBox, Is.Not.Null);
+ multiLineTextBox.Text = testDescription;
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(800));
- string expectedText = "New line text. Line1Line2 Line3";
+ string expectedText = "New line text." + "\n" +"Line1" + "\n" +"Line2 " + "\n" +"Line3";
// Get text from the textbox and verify
Assert.That(expectedText, Is.EqualTo(multiLineTextBox.Text));
}
//Test the undo and redo functionality within the text box.
[Test]
- public void textBox1_UndoText()
+ public void TextBox1_UndoText()
{
var expectedText = "";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("This is a textbox. Trying to perform Functionality test for Undo");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.CONTROL);
@@ -191,10 +192,10 @@ public void textBox1_UndoText()
}
[Test]
- public void textBox12_RedoText()
- {
+ public void TextBox12_RedoText()
+ {
var expectedText = "This is a textbox. Trying to perform Redo";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("This is a textbox. Trying to perform Redo");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
//Undo
@@ -221,9 +222,9 @@ public void textBox12_RedoText()
//Verify that users can copy and paste text from and to the text box.
[Test]
- public void textBox2_rightClickTestCut()
+ public void TextBox2_rightClickTestCut()
{
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("Hello World!Hello World!Hello World!Hello World!Hello World!Hell World!Hello World!Hello World!Hello World!");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.CONTROL);
@@ -233,52 +234,52 @@ public void textBox2_rightClickTestCut()
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
textBox.RightClick();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
- Assert.IsNotNull(textWindow);
+ Assert.That(textWindow, Is.Not.Null);
var cutText = textWindow.FindFirstDescendant(cf => cf.ByName("Cut")).AsMenuItem();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
- Assert.IsNotNull(cutText);
- Assert.IsTrue(cutText.IsEnabled);
+ Assert.That(cutText, Is.Not.Null);
+ Assert.That(cutText.IsEnabled, Is.True);
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
cutText.Click();
- Wait.UntilInputIsProcessed();
+ Wait.UntilInputIsProcessed();
}
[Test]
- public void textBox21_rightClickTestCopy()
+ public void TextBox21_rightClickTestCopy()
{
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("Hello World!Hello World!Hello World!Hello World!Hello World!Hell World!Hello World!Hello World!Hello World!");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.CONTROL);
- Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.KEY_A);
+ Keyboard.Press(FlaUI.Core.WindowsAPI.VirtualKeyShort.KEY_A);
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.KEY_A);
- Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.CONTROL);
+ Keyboard.Release(FlaUI.Core.WindowsAPI.VirtualKeyShort.CONTROL);
textBox.RightClick();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
- Assert.IsNotNull(textWindow);
+ Assert.That(textWindow, Is.Not.Null);
var pasteText = textWindow.FindFirstDescendant(cf => cf.ByName("Copy")).AsMenuItem();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
pasteText.GetClickablePoint();
- Assert.IsNotNull(pasteText);
+ Assert.That(pasteText, Is.Not.Null);
pasteText.Click();
- Wait.UntilInputIsProcessed();
+ Wait.UntilInputIsProcessed();
}
[Test]
- public void textBox212_rightClickTest_Paste()
+ public void TextBox212_rightClickTest_Paste()
{
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("Hello World!Hello World!Hello World!Hello World!Hello World!Hell World!Hello World!Hello World!Hello World!");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
textBox.RightClick();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(1000));
- Assert.IsNotNull(textWindow);
+ Assert.That(textWindow, Is.Not.Null);
var pasteText = textWindow.FindFirstDescendant(cf => cf.ByName("Paste")).AsMenuItem();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
- Assert.IsNotNull(pasteText);
+ Assert.That(pasteText, Is.Not.Null);
pasteText.Click();
- }
+ }
#endregion
@@ -286,68 +287,73 @@ public void textBox212_rightClickTest_Paste()
/* Negative Test Scenarios */
//Attempt to enter code snippets or HTML code into the input box to see if the same is rejected.
[Test]
- public void textBox3_htmlTextBox()
+ public void TextBox3_htmlTextBox()
{
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Text = string.Empty;
textBox.Enter("");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(800));
Assert.That(textBox.Text, Is.EqualTo(""));
- }
+ }
/* Test Cases For Disabled TextBox
*/
[Test]
- public void textBox3_disabledTextBoxAvailability()
+ public void TextBox3_disabledTextBoxAvailability()
{
- Assert.IsNotNull(textWindow);
- Assert.IsNotNull(disabledTextBox);
+ Assert.Multiple(() =>
+ {
+ Assert.That(textWindow, Is.Not.Null);
+ Assert.That(disabledTextBox, Is.Not.Null);
+ });
}
//Check if any pre-populated value should be displayed as per requirement.
[Test]
- public void textBox3_disabledTextBox()
+ public void TextBox3_disabledTextBox()
{
- Assert.IsNotNull(textWindow);
- Assert.IsNotNull(disabledTextBox);
+ Assert.That(textWindow, Is.Not.Null);
+ Wait.UntilInputIsProcessed();
+ Assert.That(disabledTextBox, Is.Not.Null);
Assert.That(disabledTextBox.Text, Is.EqualTo("TextBox Disabled"));
}
//Check if you cannot edit disabled TextBox.
[Test]
- public void textBox_disabledEditTextBox()
+ public void TextBox_disabledEditTextBox()
{
- Assert.IsNotNull(textWindow);
- Assert.IsNotNull(disabledTextBox);
- Assert.That(disabledTextBox.IsEnabled, Is.False);
+ Assert.That(textWindow, Is.Not.Null);
+ Wait.UntilInputIsProcessed();
+ Assert.That(disabledTextBox, Is.Not.Null);
+ Assert.That(disabledTextBox.IsEnabled, Is.False);
}
#endregion
#region UITests
[Test]
- public void textBox_clickOnTextbox()
+ public void TextBox_clickOnTextbox()
{
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
Mouse.Click(textBox.GetClickablePoint());
Assert.That(textBox.IsEnabled, Is.True);
- }
+ }
[Test]
- public void textBox_fontFamily()
+ public void TextBox_fontFamily()
{
string expected_FontFamily = "Segoe UI";
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("Hello World!");
var colorRange = textBox.Patterns.Text.Pattern;
var textFont = (string)colorRange.DocumentRange.GetAttributeValue(automation.TextAttributeLibrary.FontName);
Assert.That(textFont, Is.EqualTo(expected_FontFamily));
}
-
+
[Test]
- public void textBox_textForegroundColor()
+ public void TextBox_textForegroundColor()
{
// var automation = new UIA3Automation();
- Assert.IsNotNull(textBox);
+ Assert.That(textBox, Is.Not.Null);
textBox.Enter("Hello World!");
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(500));
var expectedColor = ColorTranslator.FromHtml("#E4000000");
@@ -356,9 +362,9 @@ public void textBox_textForegroundColor()
var actualColor = Color.FromArgb(foreColorInt);
Console.WriteLine("actualColor........{0}", actualColor);
AssertColorEquality(actualColor, Color.FromArgb(0, expectedColor));
- }
+ }
- private void AssertColorEquality(Color actual, Color expected)
+ private static void AssertColorEquality(Color actual, Color expected)
{
if (actual.ToArgb() != expected.ToArgb())
{
@@ -376,15 +382,19 @@ private void AssertColorEquality(Color actual, Color expected)
#endregion
[Test]
- public void textBox4_Cleanup()
+ public void TextBox4_Cleanup()
{
- Assert.IsNotNull(textWindow);
- textWindow.Close();
- Wait.UntilInputIsProcessed();
- Assert.IsTrue(textWindow.IsOffscreen);
- Assert.IsNotNull(mainWindow);
- mainWindow.Close();
- Assert.IsTrue(mainWindow.IsOffscreen);
+ if (app != null)
+ {
+ app.Close();
+ Console.WriteLine("Application closed successfully.");
+ Assert.That(app.Close());
+ }
+ else
+ {
+ Console.WriteLine("Application not found.");
+ Assert.That(app.Close());
+ }
}
}
}