Skip to content

Commit

Permalink
Add test for GetText with no selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed May 2, 2024
1 parent 26b0732 commit 006fd4a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/FlaUI.WebDriver.UITests/ElementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ public void GetText_Returns_Text_For_Multiple_Selection()
Assert.That(text, Is.EqualTo("ListBox Item #1, ListBox Item #2").Or.EqualTo("ListBox Item #2, ListBox Item #1"));
}

[Test]
public void GetText_Returns_Empty_String_For_No_Selection()
{
var driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
var element = driver.FindElement(ExtendedBy.AccessibilityId("ListBox"));
var item = driver.FindElement(ExtendedBy.Name("ListBox Item #1"));

new Actions(driver)
.MoveToElement(item)
.KeyDown(Keys.Control)
.Click()
.KeyUp(Keys.Control)
.Perform();

var text = element.Text;

// Seems that the order in which the selected items are returned is not guaranteed.
Assert.That(text, Is.Empty);
}

[Test]
public void Selected_NotCheckedCheckbox_ReturnsFalse()
{
Expand Down

0 comments on commit 006fd4a

Please sign in to comment.