-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Session/Element.findElement throwing (#158)
New approach from #157 : Other Selenium bindings (Java, C#) have a throwing `findElement` method, so do the same for Swift. Also refactors `poll` to remove the `PollResult` type in favor of having the closure return a `Result<Value, Error>`. A returned error allows a retry whereas a thrown error stops the polling.
- Loading branch information
1 parent
f578048
commit 1f70708
Showing
11 changed files
with
110 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// Thrown when findElement fails to locate an element. | ||
public struct ElementNotFoundError: Error, CustomStringConvertible { | ||
/// The locator that was used to search for the element. | ||
public var locator: ElementLocator | ||
|
||
/// The error that caused the element to not be found. | ||
public var sourceError: Error | ||
|
||
public init(locator: ElementLocator, sourceError: Error) { | ||
self.locator = locator | ||
self.sourceError = sourceError | ||
} | ||
|
||
/// The error response returned by the WebDriver server, if this was the source of the failure. | ||
public var errorResponse: ErrorResponse? { sourceError as? ErrorResponse } | ||
|
||
public var description: String { | ||
"Element not found using locator [\(locator.using)=\(locator.value)]: \(sourceError)" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters