Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Element Send Keys according to spec #33

Merged
merged 21 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions src/FlaUI.WebDriver.UITests/ElementTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FlaUI.WebDriver.UITests.TestUtil;
using System.Threading;
using FlaUI.WebDriver.UITests.TestUtil;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Remote;
using System;

namespace FlaUI.WebDriver.UITests
{
Expand Down Expand Up @@ -134,7 +134,51 @@ public void SendKeys_Default_IsSupported()

element.SendKeys("Hello World!");

Assert.That(element.Text, Is.EqualTo("Hello World!"));
Assert.That(element.Text, Is.EqualTo("Hello World!Test TextBox"));
}

[Test]
public void SendKeys_ShiftedCharacter_ShiftIs_Released()
{
grokys marked this conversation as resolved.
Show resolved Hide resolved
var driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox"));

element.SendKeys("!");
element.SendKeys("1");

Assert.That(element.Text, Is.EqualTo("!1Test TextBox"));
}

[Test]
public void SendKeys_DownArrow_IsSupported()
{
var driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
var element = driver.FindElement(ExtendedBy.AccessibilityId("NonEditableCombo"));

element.SendKeys(Keys.Down);

Assert.That(element.Text, Is.EqualTo("Item 2"));
}

[Test, Ignore("Alt key combinations currently fail due to https://github.com/FlaUI/FlaUI/issues/320")]
public void SendKeys_AltDownArrowEscape_IsSupported()
{
var driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
var element = driver.FindElement(ExtendedBy.AccessibilityId("NonEditableCombo"));
var expandCollapseState = element.GetDomAttribute("ExpandCollapse.ExpandCollapseState");

Assert.That(expandCollapseState, Is.EqualTo("Collapsed"));

element.SendKeys(Keys.Alt + Keys.Down);

Assert.That(expandCollapseState, Is.EqualTo("Expanded"));

Thread.Sleep(2000);

grokys marked this conversation as resolved.
Show resolved Hide resolved
Assert.That(expandCollapseState, Is.EqualTo("Collapsed"));
}

[Test]
Expand Down
3 changes: 3 additions & 0 deletions src/FlaUI.WebDriver/Action.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class Action
{
public Action(ActionSequence actionSequence, ActionItem actionItem)
{
Id = actionSequence.Id;
Type = actionSequence.Type;
SubType = actionItem.Type;
Button = actionItem.Button;
Expand All @@ -29,6 +30,7 @@ public Action(ActionSequence actionSequence, ActionItem actionItem)

public Action(Action action)
{
Id = action.Id;
Type = action.Type;
SubType = action.SubType;
Button = action.Button;
Expand All @@ -50,6 +52,7 @@ public Action(Action action)
Value = action.Value;
}

public string Id { get; set; }
public string Type { get; set; }
public string SubType { get; set; }
public int? Button { get; set; }
Expand Down
Loading
Loading