Files
elwig/Tests/E2ETests/DeliveryAdminWindowReceiptTest.cs
Lorenz Stechauner 7246852181
All checks were successful
Test / Run tests (push) Successful in 2m12s
E2ETests: Refactor to use .FindElement(By.Something())
2024-07-19 14:34:12 +02:00

86 lines
3.2 KiB
C#

using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Windows;
using Tests.WeighingTests;
namespace Tests.E2ETests {
[TestFixture, Order(2)]
public class DeliveryAdminWindowReceiptTest {
private MockScale Mock;
private AppSession Session;
[OneTimeSetUp]
public void Setup() {
Mock = new CommandMockScale(12345, ScaleHandlers.Handle_IT3000A) {
Weight = 3210,
};
Session = new(Utils.ApplicationPath, Utils.ConfigPath, WinAppDriver.WinAppDriverUrl);
Session.App.FindElement(By.Name("Stammdaten")).Click();
Thread.Sleep(500);
var window = Session.CreateWindowDriver("BaseDataWindow");
window.FindElement(By.Name("Saisons")).Click();
window.FindElement(By.Name("Neu anlegen...")).Click();
var dialog = Session.CreateWindowDriver("NewSeasonDialog");
dialog.FindElement(By.Name("Bestätigen")).Click();
dialog.Close();
Thread.Sleep(500);
window.Close();
}
[OneTimeTearDown]
public void Teardown() {
Session.Dispose();
Mock.Dispose();
}
private WindowsDriver<WindowsElement> OpenReceiptWindow() {
Session.App.FindElement(By.Name("Übernahme")).Click();
Thread.Sleep(Utils.WINDOW_OPEN_SLEEP);
return Session.CreateWindowDriver("DeliveryAdminWindow");
}
private void FinishDeliveryNote(WindowsDriver<WindowsElement> window) {
window.FindElement(By.Name("Abschließen")).Click();
Thread.Sleep(2000);
var doc = Session.CreateWindowDriver("DocumentViewerWindow");
Assert.That(doc.Title, Contains.Substring("Traubenübernahmeschein"));
Thread.Sleep(500);
doc.Close();
Thread.Sleep(500);
}
[Test]
public void Test_1_Minimal() {
var window = OpenReceiptWindow();
window.FindElement(By.WpfId("MgNrInput")).SendKeys("101" + Keys.Enter + "GV" + Keys.Enter + "73" + Keys.Enter + Keys.Enter);
Thread.Sleep(500);
FinishDeliveryNote(window);
window.Close();
}
[Test]
public void Test_2_OtherInputs() {
var window = OpenReceiptWindow();
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();
}
[Test]
public void Test_3_AttributeCultivationModifier() {
var window = OpenReceiptWindow();
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);
window.Close();
}
}
}