-
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.
Introduce ElementLocator to replace findElement overloads (#155)
- Loading branch information
1 parent
c321473
commit f578048
Showing
12 changed files
with
103 additions
and
191 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/// A locator strategy to use when searching for an element. | ||
public struct ElementLocator: Codable, Hashable { | ||
/// The locator strategy to use. | ||
public var using: String | ||
/// The search target. | ||
public var value: String | ||
|
||
public init(using: String, value: String) { | ||
self.using = using | ||
self.value = value | ||
} | ||
|
||
/// Matches an element whose class name contains the search value; compound class names are not permitted. | ||
public static func className(_ value: String) -> Self { | ||
Self(using: "class name", value: value) | ||
} | ||
|
||
/// Matches an element matching a CSS selector. | ||
public static func cssSelector(_ value: String) -> Self { | ||
Self(using: "css selector", value: value) | ||
} | ||
|
||
/// Matches an element whose ID attribute matches the search value. | ||
public static func id(_ value: String) -> Self { | ||
Self(using: "id", value: value) | ||
} | ||
|
||
/// Matches an element whose NAME attribute matches the search value. | ||
public static func name(_ value: String) -> Self { | ||
Self(using: "name", value: value) | ||
} | ||
|
||
/// Matches an anchor element whose visible text matches the search value. | ||
public static func linkText(_ value: String) -> Self { | ||
Self(using: "link text", value: value) | ||
} | ||
|
||
/// Returns an anchor element whose visible text partially matches the search value. | ||
public static func partialLinkText(_ value: String) -> Self { | ||
Self(using: "partial link text", value: value) | ||
} | ||
|
||
/// Returns an element whose tag name matches the search value. | ||
public static func tagName(_ value: String) -> Self { | ||
Self(using: "tag name", value: value) | ||
} | ||
|
||
/// Returns an element matching an XPath expression. | ||
public static func xpath(_ value: String) -> Self { | ||
Self(using: "xpath", value: value) | ||
} | ||
} |
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,8 @@ | ||
import WebDriver | ||
|
||
extension ElementLocator { | ||
/// Matches an element whose accessibility ID matches the search value. | ||
public static func accessibilityId(_ value: String) -> Self { | ||
Self(using: "accessibility id", value: value) | ||
} | ||
} |
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
Oops, something went wrong.