Skip to content

Commit

Permalink
Merge pull request #4 from Dor-bl/Actions_test
Browse files Browse the repository at this point in the history
test: ActionsTests improvements
  • Loading branch information
aristotelos authored Apr 10, 2024
2 parents d032572 + 02ec54f commit 583d2bf
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions src/FlaUI.WebDriver.UITests/ActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,44 @@ 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?.Dispose();
}

[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"));
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 "));
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 driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
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();
Assert.That(driver.SwitchTo().ActiveElement().Text, Is.EqualTo("Test TextBo"));
new Actions(_driver).KeyDown(Keys.Backspace).KeyUp(Keys.Backspace).Perform();
string activeElmentText = _driver.SwitchTo().ActiveElement().Text;
Assert.That(activeElmentText, Is.EqualTo("Test TextBo"));
}
}
}

0 comments on commit 583d2bf

Please sign in to comment.