Skip to content

Commit

Permalink
Add support for element property
Browse files Browse the repository at this point in the history
Treat element attributes and properties as equal, just like
appium-windows-driver.
  • Loading branch information
aristotelos committed Nov 20, 2024
1 parent 041bd51 commit d1650bd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ To enable easy switching from appium-windows-driver, there is a rudimentary impl
| GET | /session/{session id}/element/{element id}/selected | Is Element Selected | :white_check_mark: |
| GET | /session/{session id}/element/{element id}/displayed | Is Element Displayed | :white_check_mark: [^isdisplayed] |
| GET | /session/{session id}/element/{element id}/attribute/{name} | Get Element Attribute | :white_check_mark: [^getattribute] |
| GET | /session/{session id}/element/{element id}/property/{name} | Get Element Property | |
| GET | /session/{session id}/element/{element id}/property/{name} | Get Element Property | :white_check_mark: |
| GET | /session/{session id}/element/{element id}/css/{property name} | Get Element CSS Value | N/A |
| GET | /session/{session id}/element/{element id}/text | Get Element Text | :white_check_mark: |
| GET | /session/{session id}/element/{element id}/name | Get Element Tag Name | :white_check_mark: |
Expand Down
32 changes: 32 additions & 0 deletions src/FlaUI.WebDriver.UITests/ElementTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ public void GetAttribute_TextBox_ReturnsValue(string attributeName, string expec
Assert.That(value, Is.EqualTo(expectedValue));
}

[TestCase(["ClassName", "TextBox"])]
[TestCase(["FrameworkId", "WPF"])]
[TestCase(["NonExistent", null])]
public void GetProperty_TextBox_ReturnsValue(string attributeName, string expectedValue)
{
var driverOptions = FlaUIDriverOptions.TestApp();
using var driver = new RemoteWebDriver(WebDriverFixture.WebDriverUrl, driverOptions);
var element = driver.FindElement(ExtendedBy.AccessibilityId("TextBox"));

var value = element.GetDomProperty(attributeName);

Assert.That(value, Is.EqualTo(expectedValue));
}

[Test]
public void GetAttribute_DesktopElement_ReturnsAttribute()
{
Expand Down Expand Up @@ -395,5 +409,23 @@ public void GetAttribute_PatternProperty_ReturnsValue()

Assert.That(value, Is.EqualTo("On"));
}

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

var value = element.GetDomProperty("Toggle.ToggleState");

Assert.That(value, Is.EqualTo("Off"));

element.Click();

value = element.GetDomProperty("Toggle.ToggleState");

Assert.That(value, Is.EqualTo("On"));
}
}
}
1 change: 1 addition & 0 deletions src/FlaUI.WebDriver/Controllers/ElementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ public async Task<ActionResult> ElementSendKeys([FromRoute] string sessionId, [F
}

[HttpGet("{elementId}/attribute/{attributeId}")]
[HttpGet("{elementId}/property/{attributeId}")]
public async Task<ActionResult> GetAttribute([FromRoute] string sessionId, [FromRoute] string elementId, [FromRoute] string attributeId)
{
var session = GetSession(sessionId);
Expand Down

0 comments on commit d1650bd

Please sign in to comment.