diff --git a/README.md b/README.md index f10bd76..4336114 100644 --- a/README.md +++ b/README.md @@ -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: | diff --git a/src/FlaUI.WebDriver.UITests/ElementTests.cs b/src/FlaUI.WebDriver.UITests/ElementTests.cs index 431c947..2f20192 100644 --- a/src/FlaUI.WebDriver.UITests/ElementTests.cs +++ b/src/FlaUI.WebDriver.UITests/ElementTests.cs @@ -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() { @@ -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")); + } } } diff --git a/src/FlaUI.WebDriver/Controllers/ElementController.cs b/src/FlaUI.WebDriver/Controllers/ElementController.cs index 41d358c..de6b836 100644 --- a/src/FlaUI.WebDriver/Controllers/ElementController.cs +++ b/src/FlaUI.WebDriver/Controllers/ElementController.cs @@ -229,6 +229,7 @@ public async Task ElementSendKeys([FromRoute] string sessionId, [F } [HttpGet("{elementId}/attribute/{attributeId}")] + [HttpGet("{elementId}/property/{attributeId}")] public async Task GetAttribute([FromRoute] string sessionId, [FromRoute] string elementId, [FromRoute] string attributeId) { var session = GetSession(sessionId);