E2ETests: Refactor to use .FindElement(By.Something())
All checks were successful
Test / Run tests (push) Successful in 2m12s
All checks were successful
Test / Run tests (push) Successful in 2m12s
This commit is contained in:
@ -39,7 +39,7 @@ namespace Tests.E2ETests {
|
||||
GC.SuppressFinalize(this);
|
||||
App.Close();
|
||||
try {
|
||||
Desktop.FindElementByName("Ja").Click();
|
||||
Desktop.FindElement(By.Name("Ja")).Click();
|
||||
} catch { }
|
||||
App.Dispose();
|
||||
Desktop.Close();
|
||||
|
@ -3,7 +3,7 @@ using OpenQA.Selenium.Appium.Windows;
|
||||
using Tests.WeighingTests;
|
||||
|
||||
namespace Tests.E2ETests {
|
||||
[TestFixture]
|
||||
[TestFixture, Order(2)]
|
||||
public class DeliveryAdminWindowReceiptTest {
|
||||
|
||||
private MockScale Mock;
|
||||
@ -15,13 +15,13 @@ namespace Tests.E2ETests {
|
||||
Weight = 3210,
|
||||
};
|
||||
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
|
||||
Session.App.FindElementByName("Stammdaten").Click();
|
||||
Session.App.FindElement(By.Name("Stammdaten")).Click();
|
||||
Thread.Sleep(500);
|
||||
var window = Session.CreateWindowDriver("BaseDataWindow");
|
||||
window.FindElementByName("Saisons").Click();
|
||||
window.FindElementByName("Neu anlegen...").Click();
|
||||
window.FindElement(By.Name("Saisons")).Click();
|
||||
window.FindElement(By.Name("Neu anlegen...")).Click();
|
||||
var dialog = Session.CreateWindowDriver("NewSeasonDialog");
|
||||
dialog.FindElementByName("Bestätigen").Click();
|
||||
dialog.FindElement(By.Name("Bestätigen")).Click();
|
||||
dialog.Close();
|
||||
Thread.Sleep(500);
|
||||
window.Close();
|
||||
@ -34,13 +34,13 @@ namespace Tests.E2ETests {
|
||||
}
|
||||
|
||||
private WindowsDriver<WindowsElement> OpenReceiptWindow() {
|
||||
Session.App.FindElementByName("Übernahme").Click();
|
||||
Session.App.FindElement(By.Name("Übernahme")).Click();
|
||||
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
|
||||
return Session.CreateWindowDriver("DeliveryAdminWindow");
|
||||
}
|
||||
|
||||
private void FinishDeliveryNote(WindowsDriver<WindowsElement> window) {
|
||||
window.FindElementByName("Abschließen").Click();
|
||||
window.FindElement(By.Name("Abschließen")).Click();
|
||||
Thread.Sleep(2000);
|
||||
var doc = Session.CreateWindowDriver("DocumentViewerWindow");
|
||||
Assert.That(doc.Title, Contains.Substring("Traubenübernahmeschein"));
|
||||
@ -52,7 +52,7 @@ namespace Tests.E2ETests {
|
||||
[Test]
|
||||
public void Test_1_Minimal() {
|
||||
var window = OpenReceiptWindow();
|
||||
window.FindById("MgNrInput").SendKeys("101" + Keys.Enter + "GV" + Keys.Enter + "73" + Keys.Enter + Keys.Enter);
|
||||
window.FindElement(By.WpfId("MgNrInput")).SendKeys("101" + Keys.Enter + "GV" + Keys.Enter + "73" + Keys.Enter + Keys.Enter);
|
||||
Thread.Sleep(500);
|
||||
FinishDeliveryNote(window);
|
||||
window.Close();
|
||||
@ -61,10 +61,10 @@ namespace Tests.E2ETests {
|
||||
[Test]
|
||||
public void Test_2_OtherInputs() {
|
||||
var window = OpenReceiptWindow();
|
||||
window.FindById("MemberInput").SendKeys("Mustermann Max");
|
||||
window.SelectComboBoxItemByText("WineVarietyInput", "Zweigelt");
|
||||
window.FindById("GradationKmwInput").SendKeys("18");
|
||||
window.FindElementByName("Wiegen").Click();
|
||||
window.FindElement(By.WpfId("MemberInput")).SendKeys("Mustermann Max");
|
||||
window.FindElement(By.WpfId("WineVarietyInput")).SelectItem("Zweigelt");
|
||||
window.FindElement(By.WpfId("GradationKmwInput")).SendKeys("18");
|
||||
window.FindElement(By.Name("Wiegen")).Click();
|
||||
Thread.Sleep(500);
|
||||
FinishDeliveryNote(window);
|
||||
window.Close();
|
||||
@ -73,9 +73,9 @@ namespace Tests.E2ETests {
|
||||
[Test]
|
||||
public void Test_3_AttributeCultivationModifier() {
|
||||
var window = OpenReceiptWindow();
|
||||
window.FindById("MgNrInput").SendKeys("102" + Keys.Enter + "GVK");
|
||||
window.SelectComboBoxItemByText("CultivationInput", "Bio");
|
||||
window.FindById("GradationOeInput").SendKeys("73" + Keys.Enter + Keys.Enter);
|
||||
window.FindElement(By.WpfId("MgNrInput")).SendKeys("102" + Keys.Enter + "GVK");
|
||||
window.FindElement(By.WpfId("CultivationInput")).SelectItem("Bio");
|
||||
window.FindElement(By.WpfId("GradationOeInput")).SendKeys("73" + Keys.Enter + Keys.Enter);
|
||||
|
||||
Thread.Sleep(500);
|
||||
FinishDeliveryNote(window);
|
||||
|
@ -1,5 +1,5 @@
|
||||
namespace Tests.E2ETests {
|
||||
[TestFixture]
|
||||
[TestFixture, Order(1)]
|
||||
public class MainWindowTest {
|
||||
|
||||
private AppSession Session;
|
||||
@ -17,7 +17,7 @@
|
||||
[Test]
|
||||
public void Test_Open_MemberAdminWindow() {
|
||||
Assert.DoesNotThrow(() => {
|
||||
Session.App.FindElementByName("Mitglieder").Click();
|
||||
Session.App.FindElement(By.Name("Mitglieder")).Click();
|
||||
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
|
||||
var window = Session.CreateWindowDriver("MemberAdminWindow");
|
||||
Assert.That(window.Title, Is.EqualTo("Mitglieder - Elwig"));
|
||||
@ -28,7 +28,7 @@
|
||||
[Test]
|
||||
public void Test_Open_DeliveryAdminWindow() {
|
||||
Assert.DoesNotThrow(() => {
|
||||
Session.App.FindElementByName("Lieferungen").Click();
|
||||
Session.App.FindElement(By.Name("Lieferungen")).Click();
|
||||
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
|
||||
var window = Session.CreateWindowDriver("DeliveryAdminWindow");
|
||||
Assert.That(window.Title, Is.EqualTo("Lieferungen - Elwig"));
|
||||
@ -39,7 +39,7 @@
|
||||
[Test]
|
||||
public void Test_Open_BaseDataWindow() {
|
||||
Assert.DoesNotThrow(() => {
|
||||
Session.App.FindElementByName("Stammdaten").Click();
|
||||
Session.App.FindElement(By.Name("Stammdaten")).Click();
|
||||
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
|
||||
var window = Session.CreateWindowDriver("BaseDataWindow");
|
||||
Assert.That(window.Title, Is.EqualTo("Stammdaten - Elwig"));
|
||||
|
@ -1,7 +1,7 @@
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
|
||||
namespace Tests.E2ETests {
|
||||
[TestFixture]
|
||||
[TestFixture, Order(3)]
|
||||
public class MemberAdminWindowTest {
|
||||
|
||||
private AppSession Session;
|
||||
@ -10,7 +10,7 @@ namespace Tests.E2ETests {
|
||||
[OneTimeSetUp]
|
||||
public void WindowSetup() {
|
||||
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
|
||||
Session.App.FindElementByName("Mitglieder").Click();
|
||||
Session.App.FindElement(By.Name("Mitglieder")).Click();
|
||||
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
|
||||
Window = Session.CreateWindowDriver("MemberAdminWindow");
|
||||
}
|
||||
@ -24,93 +24,93 @@ namespace Tests.E2ETests {
|
||||
|
||||
[TearDown]
|
||||
public void Teardown() {
|
||||
Window!.FindById("SearchInput").Clear();
|
||||
Window.FindElement(By.WpfId("SearchInput")).Clear();
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_1_CreateMember() {
|
||||
Window!.FindById("NewMemberButton").Click();
|
||||
Window.FindElement(By.WpfId("NewMemberButton")).Click();
|
||||
|
||||
Window.FindById("MgNrInput").Clear();
|
||||
Window.FindById("MgNrInput").SendKeys("9999");
|
||||
Window.FindElement(By.WpfId("MgNrInput")).Clear();
|
||||
Window.FindElement(By.WpfId("MgNrInput")).SendKeys("9999");
|
||||
|
||||
Window.FindById("GivenNameInput").SendKeys("Norbert");
|
||||
Window.FindById("FamilyNameInput").SendKeys("Neuling");
|
||||
Window.FindById("PrefixInput").SendKeys("Ing.");
|
||||
Window.FindById("SuffixInput").SendKeys("jun.");
|
||||
Window.FindById("BirthdayInput").SendKeys("1987");
|
||||
Window.FindElement(By.WpfId("GivenNameInput")).SendKeys("Norbert");
|
||||
Window.FindElement(By.WpfId("FamilyNameInput")).SendKeys("Neuling");
|
||||
Window.FindElement(By.WpfId("PrefixInput")).SendKeys("Ing.");
|
||||
Window.FindElement(By.WpfId("SuffixInput")).SendKeys("jun.");
|
||||
Window.FindElement(By.WpfId("BirthdayInput")).SendKeys("1987");
|
||||
|
||||
Window.FindById("AddressInput").SendKeys("Musterstraße 9");
|
||||
Window.FindById("PlzInput").SendKeys("2120");
|
||||
Window.SelectComboBoxItemByCount("OrtInput", 1);
|
||||
Window.FindElement(By.WpfId("AddressInput")).SendKeys("Musterstraße 9");
|
||||
Window.FindElement(By.WpfId("PlzInput")).SendKeys("2120");
|
||||
Window.FindElement(By.WpfId("OrtInput")).SelectItem(1);
|
||||
|
||||
Window.FindById("EmailAddress1Input").SendKeys("norbert.neuling@aon.at");
|
||||
Window.FindById("EmailAddress2Input").SendKeys("nathalie.neuling@aon.at");
|
||||
Window.FindElement(By.WpfId("EmailAddress1Input")).SendKeys("norbert.neuling@aon.at");
|
||||
Window.FindElement(By.WpfId("EmailAddress2Input")).SendKeys("nathalie.neuling@aon.at");
|
||||
|
||||
Window.SelectComboBoxItemByCount("PhoneNr1TypeInput", 1);
|
||||
Window.FindById("PhoneNr1Input").SendKeys("012345678");
|
||||
Window.FindElement(By.WpfId("PhoneNr1TypeInput")).SelectItem(1);
|
||||
Window.FindElement(By.WpfId("PhoneNr1Input")).SendKeys("012345678");
|
||||
|
||||
Window.SelectComboBoxItemByCount("PhoneNr2TypeInput", 2);
|
||||
Window.FindById("PhoneNr2Input").SendKeys("0664123456");
|
||||
Window.FindElement(By.WpfId("PhoneNr2TypeInput")).SelectItem(2);
|
||||
Window.FindElement(By.WpfId("PhoneNr2Input")).SendKeys("0664123456");
|
||||
|
||||
Window.FindById("IbanInput").SendKeys("AT611904300234573201");
|
||||
Window.FindById("BicInput").SendKeys("RLNWATWWWDF");
|
||||
Window.FindElement(By.WpfId("IbanInput")).SendKeys("AT611904300234573201");
|
||||
Window.FindElement(By.WpfId("BicInput")).SendKeys("RLNWATWWWDF");
|
||||
|
||||
Window.FindById("UstIdNrInput").SendKeys("ATU66192906"); // TODO: Testdaten?
|
||||
Window.FindById("LfbisNrInput").SendKeys("1251074"); // TODO: Testdaten?
|
||||
Window.FindElement(By.WpfId("UstIdNrInput")).SendKeys("ATU66192906"); // TODO: Testdaten?
|
||||
Window.FindElement(By.WpfId("LfbisNrInput")).SendKeys("1251074"); // TODO: Testdaten?
|
||||
|
||||
Window.FindById("BuchführendInput").Click();
|
||||
Window.FindById("OrganicInput").Click();
|
||||
Window.FindElement(By.WpfId("BuchführendInput")).Click();
|
||||
Window.FindElement(By.WpfId("OrganicInput")).Click();
|
||||
|
||||
Window.FindById("BillingNameInput").SendKeys("Neuling KG");
|
||||
Window.FindById("BillingAddressInput").SendKeys("Betriebsstraße 1");
|
||||
Window.FindById("BillingPlzInput").SendKeys("2120");
|
||||
Window.SelectComboBoxItemByCount("BillingOrtInput", 2);
|
||||
Window.FindElement(By.WpfId("BillingNameInput")).SendKeys("Neuling KG");
|
||||
Window.FindElement(By.WpfId("BillingAddressInput")).SendKeys("Betriebsstraße 1");
|
||||
Window.FindElement(By.WpfId("BillingPlzInput")).SendKeys("2120");
|
||||
Window.FindElement(By.WpfId("BillingOrtInput")).SelectItem(2);
|
||||
|
||||
Window.FindById("BusinessSharesInput").SendKeys("10");
|
||||
Window.SelectComboBoxItemByText("BranchInput", "Matzen");
|
||||
Window.SelectComboBoxItemByCount("DefaultKgInput", 3);
|
||||
Window.FindElement(By.WpfId("BusinessSharesInput")).SendKeys("10");
|
||||
Window.FindElement(By.WpfId("BranchInput")).SelectItem("Matzen");
|
||||
Window.FindElement(By.WpfId("DefaultKgInput")).SelectItem(3);
|
||||
|
||||
Window.FindById("VollLieferantInput").Click();
|
||||
Window.FindById("FunkionärInput").Click();
|
||||
Window.FindElement(By.WpfId("VollLieferantInput")).Click();
|
||||
Window.FindElement(By.WpfId("FunkionärInput")).Click();
|
||||
|
||||
Window.FindById("CommentInput").SendKeys("Die lieben Mustermänner und Musterfrauen!");
|
||||
Window.FindById("ContactEmailInput").Click();
|
||||
Window.FindElement(By.WpfId("CommentInput")).SendKeys("Die lieben Mustermänner und Musterfrauen!");
|
||||
Window.FindElement(By.WpfId("ContactEmailInput")).Click();
|
||||
|
||||
Window.FindById("SaveButton").Click();
|
||||
Window.FindElement(By.WpfId("SaveButton")).Click();
|
||||
|
||||
Window.FindById("SearchInput").SendKeys("9999");
|
||||
Window.FindElement(By.WpfId("SearchInput")).SendKeys("9999");
|
||||
Thread.Sleep(500);
|
||||
var memberListRow = Window.FindById("MemberList").FindElementByClassName("DataGridRow");
|
||||
var memberListRow = Window.FindElement(By.WpfId("MemberList")).FindElement(By.ClassName("DataGridRow"));
|
||||
Assert.Multiple(() => {
|
||||
Assert.That(memberListRow, Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("9999 "), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("Norbert"), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("Neuling"), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("9999 ")), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("Norbert")), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("Neuling")), Is.Not.Null);
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_2_EditMember() {
|
||||
Window!.FindById("SearchInput").SendKeys("9999");
|
||||
Window!.FindElement(By.WpfId("SearchInput")).SendKeys("9999");
|
||||
Thread.Sleep(500);
|
||||
var memberList = Window.FindById("MemberList");
|
||||
var memberList = Window.FindElement(By.WpfId("MemberList"));
|
||||
Assert.That(memberList, Is.Not.Null);
|
||||
|
||||
var memberListRows = memberList.FindElementsByClassName("DataGridRow");
|
||||
var memberListRows = memberList.FindElements(By.ClassName("DataGridRow"));
|
||||
Assert.That(memberListRows, Has.Count.EqualTo(1));
|
||||
|
||||
Window.FindById("EditMemberButton").Click();
|
||||
Window.FindElement(By.WpfId("EditMemberButton")).Click();
|
||||
|
||||
var businessSharesInput = Window.FindById("BusinessSharesInput");
|
||||
var businessSharesInput = Window.FindElement(By.WpfId("BusinessSharesInput"));
|
||||
Assert.That(businessSharesInput, Is.Not.Null);
|
||||
|
||||
var businessShares = int.Parse(businessSharesInput.Text);
|
||||
businessSharesInput.Clear();
|
||||
businessSharesInput.SendKeys($"{businessShares + 5}");
|
||||
|
||||
Window.FindById("SaveButton").Click();
|
||||
Window.FindElement(By.WpfId("SaveButton")).Click();
|
||||
|
||||
var newBusinessShares = int.Parse(businessSharesInput.Text);
|
||||
Assert.That(newBusinessShares, Is.EqualTo(businessShares + 5));
|
||||
@ -118,28 +118,28 @@ namespace Tests.E2ETests {
|
||||
|
||||
[Test]
|
||||
public void Test_3_DeleteMember() {
|
||||
Window!.FindById("SearchInput").SendKeys("9999");
|
||||
Window!.FindElement(By.WpfId("SearchInput")).SendKeys("9999");
|
||||
Thread.Sleep(500);
|
||||
var memberList = Window.FindById("MemberList");
|
||||
var memberList = Window.FindElement(By.WpfId("MemberList"));
|
||||
Assert.That(memberList, Is.Not.Null);
|
||||
|
||||
var memberListRows = memberList.FindElementsByClassName("DataGridRow");
|
||||
var memberListRows = memberList.FindElements(By.ClassName("DataGridRow"));
|
||||
Assert.That(memberListRows, Has.Count.EqualTo(1));
|
||||
|
||||
var memberListRow = memberListRows.First();
|
||||
Assert.Multiple(() => {
|
||||
Assert.That(memberListRow, Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("9999 "), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("Norbert"), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElementByName("Neuling"), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("9999 ")), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("Norbert")), Is.Not.Null);
|
||||
Assert.That(memberListRow.FindElement(By.Name("Neuling")), Is.Not.Null);
|
||||
});
|
||||
|
||||
Window.FindById("DeleteMemberButton").Click();
|
||||
Window.FindElement(By.WpfId("DeleteMemberButton")).Click();
|
||||
var dialog = Session.CreateWindowDriver("DeleteMemberDialog");
|
||||
dialog.FindById("NameInput").SendKeys("9999 Ing. Norbert Neuling jun.");
|
||||
dialog.FindById("ConfirmButton").Click();
|
||||
dialog.FindElement(By.WpfId("NameInput")).SendKeys("9999 Ing. Norbert Neuling jun.");
|
||||
dialog.FindElement(By.WpfId("ConfirmButton")).Click();
|
||||
|
||||
memberListRows = memberList.FindElementsByClassName("DataGridRow");
|
||||
memberListRows = memberList.FindElements(By.ClassName("DataGridRow"));
|
||||
Assert.That(memberListRows, Has.Count.EqualTo(0));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
using OpenQA.Selenium;
|
||||
using OpenQA.Selenium.Appium.Windows;
|
||||
using OpenQA.Selenium.Appium;
|
||||
|
||||
namespace Tests.E2ETests {
|
||||
public static class Utils {
|
||||
@ -10,22 +10,22 @@ namespace Tests.E2ETests {
|
||||
public static readonly string ConfigPath = Path.GetFullPath(@"..\..\..\..\Tests\config.test.ini");
|
||||
public static readonly string TestDatabasePath = Path.GetFullPath(@"..\..\..\..\Tests\ElwigTestDB.sqlite3");
|
||||
|
||||
public static WindowsElement FindById(this WindowsDriver<WindowsElement> session, string accessibilityId) {
|
||||
return session.FindElementByAccessibilityId(accessibilityId);
|
||||
}
|
||||
|
||||
public static void SelectComboBoxItemByCount(this WindowsDriver<WindowsElement> session, string accessibilityId, int count) {
|
||||
var element = session.FindElementByAccessibilityId(accessibilityId);
|
||||
public static void SelectItem(this IWebElement element, int count) {
|
||||
element.Click();
|
||||
element.SendKeys(string.Concat(Enumerable.Repeat(Keys.Down, count)));
|
||||
element.SendKeys(Keys.Enter);
|
||||
}
|
||||
|
||||
public static void SelectComboBoxItemByText(this WindowsDriver<WindowsElement> session, string accessibilityId, string text) {
|
||||
var element = session.FindElementByAccessibilityId(accessibilityId);
|
||||
public static void SelectItem(this IWebElement element, string text) {
|
||||
element.Click();
|
||||
element.SendKeys(text);
|
||||
element.SendKeys(Keys.Enter);
|
||||
}
|
||||
}
|
||||
|
||||
public class By : OpenQA.Selenium.By {
|
||||
public static OpenQA.Selenium.By WpfId(string wpfName) {
|
||||
return new ByAccessibilityId(wpfName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user