From 9b242292ed977c5077e59bc56f65503e90186ece Mon Sep 17 00:00:00 2001 From: Dor-bl Date: Sun, 31 Mar 2024 06:58:57 +0300 Subject: [PATCH 1/4] test: ActionsTests improvements --- src/FlaUI.WebDriver.UITests/ActionsTest.cs | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/FlaUI.WebDriver.UITests/ActionsTest.cs b/src/FlaUI.WebDriver.UITests/ActionsTest.cs index 7eef541..70c7f59 100644 --- a/src/FlaUI.WebDriver.UITests/ActionsTest.cs +++ b/src/FlaUI.WebDriver.UITests/ActionsTest.cs @@ -9,24 +9,35 @@ namespace FlaUI.WebDriver.UITests [TestFixture] public class ActionsTests { + private RemoteWebDriver driver; + + [SetUp] + public void Setup() + { + var driverOptions = FlaUIDriverOptions.TestApp(); + driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions); + } + + [TearDown] + public void Teardown() + { + driver?.Quit(); + } + [Test] public void PerformActions_KeyDownKeyUp_IsSupported() { - var driverOptions = FlaUIDriverOptions.TestApp(); - using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions); var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); element.Click(); new Actions(driver).KeyDown(Keys.Control).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).KeyUp(Keys.Control).Perform(); - - Assert.That(driver.SwitchTo().ActiveElement().Text, Is.EqualTo("Test ")); + string activeElementText = driver.SwitchTo().ActiveElement().Text; + Assert.That(activeElementText, Is.EqualTo("Test ")); } [Test] public void ReleaseActions_Default_ReleasesKeys() { - var driverOptions = FlaUIDriverOptions.TestApp(); - using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions); var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); element.Click(); new Actions(driver).KeyDown(Keys.Control).Perform(); @@ -34,7 +45,8 @@ public void ReleaseActions_Default_ReleasesKeys() driver.ResetInputState(); new Actions(driver).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).Perform(); - Assert.That(driver.SwitchTo().ActiveElement().Text, Is.EqualTo("Test TextBo")); + string activeElmentText = driver.SwitchTo().ActiveElement().Text; + Assert.That(activeElmentText, Is.EqualTo("Test TextBo")); } } } From 294c29c6d3e6307db9c474243ca7985c37e70ed2 Mon Sep 17 00:00:00 2001 From: Dor Blayzer <59066376+Dor-bl@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:58:05 +0300 Subject: [PATCH 2/4] Update src/FlaUI.WebDriver.UITests/ActionsTest.cs Co-authored-by: aristotelos --- src/FlaUI.WebDriver.UITests/ActionsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FlaUI.WebDriver.UITests/ActionsTest.cs b/src/FlaUI.WebDriver.UITests/ActionsTest.cs index 70c7f59..f0143f1 100644 --- a/src/FlaUI.WebDriver.UITests/ActionsTest.cs +++ b/src/FlaUI.WebDriver.UITests/ActionsTest.cs @@ -9,7 +9,7 @@ namespace FlaUI.WebDriver.UITests [TestFixture] public class ActionsTests { - private RemoteWebDriver driver; + private RemoteWebDriver _driver; [SetUp] public void Setup() From f8d6ed5a1317df61551f3133a54139d31de7edd3 Mon Sep 17 00:00:00 2001 From: Dor Blayzer <59066376+Dor-bl@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:58:11 +0300 Subject: [PATCH 3/4] Update src/FlaUI.WebDriver.UITests/ActionsTest.cs Co-authored-by: aristotelos --- src/FlaUI.WebDriver.UITests/ActionsTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FlaUI.WebDriver.UITests/ActionsTest.cs b/src/FlaUI.WebDriver.UITests/ActionsTest.cs index f0143f1..d0d924f 100644 --- a/src/FlaUI.WebDriver.UITests/ActionsTest.cs +++ b/src/FlaUI.WebDriver.UITests/ActionsTest.cs @@ -21,7 +21,7 @@ public void Setup() [TearDown] public void Teardown() { - driver?.Quit(); + driver?.Dispose(); } [Test] From 02ec54f8ad7b11cffe7db2d45950ae4624f01457 Mon Sep 17 00:00:00 2001 From: Dor-bl Date: Tue, 9 Apr 2024 23:09:50 +0300 Subject: [PATCH 4/4] fix: Update _driver usage --- src/FlaUI.WebDriver.UITests/ActionsTest.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/FlaUI.WebDriver.UITests/ActionsTest.cs b/src/FlaUI.WebDriver.UITests/ActionsTest.cs index d0d924f..ddcd386 100644 --- a/src/FlaUI.WebDriver.UITests/ActionsTest.cs +++ b/src/FlaUI.WebDriver.UITests/ActionsTest.cs @@ -15,37 +15,37 @@ public class ActionsTests public void Setup() { var driverOptions = FlaUIDriverOptions.TestApp(); - driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions); + _driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions); } [TearDown] public void Teardown() { - driver?.Dispose(); + _driver?.Dispose(); } [Test] public void PerformActions_KeyDownKeyUp_IsSupported() { - var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); + var element = _driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); element.Click(); - new Actions(driver).KeyDown(Keys.Control).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).KeyUp(Keys.Control).Perform(); - string activeElementText = driver.SwitchTo().ActiveElement().Text; + new Actions(_driver).KeyDown(Keys.Control).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).KeyUp(Keys.Control).Perform(); + string activeElementText = _driver.SwitchTo().ActiveElement().Text; Assert.That(activeElementText, Is.EqualTo("Test ")); } [Test] public void ReleaseActions_Default_ReleasesKeys() { - var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); + var element = _driver.FindElement(ExtendedBy.AccessibilityId("TextBox")); element.Click(); - new Actions(driver).KeyDown(Keys.Control).Perform(); + new Actions(_driver).KeyDown(Keys.Control).Perform(); - driver.ResetInputState(); + _driver.ResetInputState(); - new Actions(driver).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).Perform(); - string activeElmentText = driver.SwitchTo().ActiveElement().Text; + new Actions(_driver).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).Perform(); + string activeElmentText = _driver.SwitchTo().ActiveElement().Text; Assert.That(activeElmentText, Is.EqualTo("Test TextBo")); } }