diff --git a/Docs/SupportedAPIs.md b/Docs/SupportedAPIs.md index ba8ca67..7e45a35 100644 --- a/Docs/SupportedAPIs.md +++ b/Docs/SupportedAPIs.md @@ -69,5 +69,5 @@ Contributions to expand support to unimplemented functionality are always welcom | POST | `/session/:sessionId/window/:windowHandle/position` | Supported | Not implemented | | GET | `/session/:sessionId/window/:windowHandle/position` | Supported | Not implemented | | POST | `/session/:sessionId/window/:windowHandle/maximize` | Supported | Not implemented | -| GET | `/session/:sessionId/window_handle` | Supported | `Session.windowHandle()`| -| GET | `/session/:sessionId/window_handles` | Supported | `Session.windowHandles()`| \ No newline at end of file +| GET | `/session/:sessionId/window_handle` | Supported | `Session.windowHandle`| +| GET | `/session/:sessionId/window_handles` | Supported | `Session.windowHandles`| \ No newline at end of file diff --git a/Sources/WebDriver/Session.swift b/Sources/WebDriver/Session.swift index 29675f0..3144b87 100644 --- a/Sources/WebDriver/Session.swift +++ b/Sources/WebDriver/Session.swift @@ -328,15 +328,19 @@ public class Session { } /// - Returns: Current window handle - public func windowHandle() throws -> String { - let response = try webDriver.send(Requests.SessionWindowHandle(session: id)) - return response.value + public var windowHandle: String { + get throws { + let response = try webDriver.send(Requests.SessionWindowHandle(session: id)) + return response.value + } } /// - Returns: Array of window handles - public func windowHandles() throws -> [String] { - let response = try webDriver.send(Requests.SessionWindowHandles(session: id)) - return response.value + public var windowHandles: [String] { + get throws { + let response = try webDriver.send(Requests.SessionWindowHandles(session: id)) + return response.value + } } /// Deletes the current session. diff --git a/Tests/UnitTests/APIToRequestMappingTests.swift b/Tests/UnitTests/APIToRequestMappingTests.swift index cfe5f11..50abe89 100644 --- a/Tests/UnitTests/APIToRequestMappingTests.swift +++ b/Tests/UnitTests/APIToRequestMappingTests.swift @@ -221,7 +221,7 @@ class APIToRequestMappingTests: XCTestCase { mockWebDriver.expect(path: "session/mySession/window_handle", method: .get, type: Requests.SessionWindowHandle.self) { ResponseWithValue(.init("myWindow")) } - XCTAssert(try session.windowHandle() == "myWindow") + XCTAssert(try session.windowHandle == "myWindow") } func testWindowHandles() throws { @@ -231,7 +231,7 @@ class APIToRequestMappingTests: XCTestCase { mockWebDriver.expect(path: "session/mySession/window_handles", method: .get, type: Requests.SessionWindowHandles.self) { ResponseWithValue(.init(["myWindow", "myWindow"])) } - XCTAssert(try session.windowHandles() == ["myWindow", "myWindow"]) + XCTAssert(try session.windowHandles == ["myWindow", "myWindow"]) } func testSessionSource() throws {