Skip to content

Commit

Permalink
Merge pull request #4 from ashi-psn/develop
Browse files Browse the repository at this point in the history
fix ChromeOptionInitalization
  • Loading branch information
ashi-psn authored Jun 15, 2022
2 parents 477f163 + 88bb0b3 commit 511d222
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 303 deletions.
115 changes: 0 additions & 115 deletions .swiftpm/xcode/xcshareddata/xcschemes/swift-webdriver.xcscheme

This file was deleted.

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

9 changes: 3 additions & 6 deletions Example/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import PackageDescription
let package = Package(
name: "SeleniumSwiftExample",
platforms: [
.macOS(.v10_12),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6)
.macOS(.v12),
],
dependencies: [
.package(name: "selenium-swift", path: "../")
.package(name: "SwiftWebDriver", path: "../")
],
targets: [
.executableTarget(
name: "SeleniumSwiftExample",
dependencies: [
.product(name: "SeleniumSwift", package: "selenium-swift")
.product(name: "SwiftWebDriver", package: "SwiftWebDriver")
]),
.testTarget(
name: "SeleniumSwiftExampleTests",
Expand Down
30 changes: 26 additions & 4 deletions Example/Sources/SeleniumSwiftExample/main.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import SeleniumSwift
import SwiftWebDriver

print("Hello, world!")
let chromeOption = try ChromeOptions(
args: [
Args(.headless),
]
)

let chromeOption = ChromeOptions(
let selenium = SeleniumSwift(browser: .chrome(options: ChromeOptions())
let chromeDriver = try ChromeDriver(
driverURLString: "http://localhost:9515",
browserObject: chromeOption
)

let driver = WebDriver(
driver: chromeDriver
)

Task.detached {
do {
let status = try await driver.status()
print(status)
let sessionId = try await driver.start()
print(sessionId)
try await driver.stop()
} catch {
print(error)
}
}
72 changes: 11 additions & 61 deletions Sources/SwiftWebDriver/WebDriver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WebDriver<T: Driver> {

/// init webDriver
/// - Parameter driver:Driver
required init(driver: T) {
public required init(driver: T) {
self.driver = driver
}

Expand All @@ -28,13 +28,6 @@ public class WebDriver<T: Driver> {
return result
}

@discardableResult
/// webdriver start method
/// - Returns: session id
public func start() throws -> EventLoopFuture<String> {
return driver.start()
}

/// webdriver stop method
/// - Returns: nil
@discardableResult
Expand All @@ -43,14 +36,6 @@ public class WebDriver<T: Driver> {
return try await driver.stop()
}



/// webdriver stop method
/// - Returns: nil
@discardableResult
public func stop() throws -> EventLoopFuture<String?> {
return try driver.stop()
}


/// webdriver status
Expand All @@ -61,27 +46,9 @@ public class WebDriver<T: Driver> {
}


/// webdriver status
/// - Returns: StatusResponse
public func status() throws -> EventLoopFuture<StatusResponse> {
return driver.status()
}

public func getNavigation() throws -> EventLoopFuture<GetNavigationResponse> {
return try driver.getNavigation()
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func getNavigation() async throws -> GetNavigationResponse {
return try await getNavigation().get()
}

/// load Page
/// - Parameter url: load page url
/// - Returns: EventLoopFuture<PostNavigationResponse>
@discardableResult
public func navigateTo(url: String) throws -> EventLoopFuture<PostNavigationResponse> {
return try driver.postNavigation(requestURL: url)
return try await driver.getNavigation()
}


Expand All @@ -90,61 +57,44 @@ public class WebDriver<T: Driver> {
/// - Returns: PostNavigationResponse
@discardableResult
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func navigateTo(url: String) async throws -> PostNavigationResponse {
return try await navigateTo(url: url).get()
public func navigateTo(urlString: String) async throws -> PostNavigationResponse {
return try await driver.postNavigation(requestURL: urlString)
}

@discardableResult
public func navigateTo(url: URL) async throws -> PostNavigationResponse {
return try await navigateTo(url: url.absoluteString).get()
return try await navigateTo(urlString: url.absoluteString)
}


/// navigation back
/// - Returns: EventLoopFuture<PostNavigationBackResponse>
public func navigationBack() throws -> EventLoopFuture<PostNavigationBackResponse> {
return try driver.postNavigationBack()
}

/// navigation back
/// - Returns: EventLoopFuture<PostNavigationBackResponse>
/// - Returns: PostNavigationBackResponse
@discardableResult
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func navigationBack() async throws -> PostNavigationBackResponse {
return try await driver.postNavigationBack().get()
return try await driver.postNavigationBack()
}

/// navigation forward
/// - Returns: EventLoopFuture<PostNavigationForwardResponse>
public func navigatonForward() throws -> EventLoopFuture<PostNavigationForwardResponse> {
return try driver.postNavigationForward()
}

/// navigation forward
/// - Returns: EventLoopFuture<PostNavigationForwardResponse>
/// - Returns: PostNavigationForwardResponse<PostNavigationForwardResponse>
@discardableResult
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func navigatonForward() async throws -> PostNavigationForwardResponse {
return try await navigatonForward().get()
return try await driver.postNavigationForward()
}

public func navigatonRefresh() throws -> EventLoopFuture<PostNavigationRefreshResponse> {
return try driver.postNavigationRefresh()
}

@discardableResult
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func navigatonRefresh() async throws -> PostNavigationRefreshResponse {
return try await navigatonRefresh().get()
return try await driver.postNavigationRefresh()
}

public func navigationTitle() throws -> EventLoopFuture<GetNavigationTitleResponse> {
return try driver.getNavigationTitle()
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
public func navigationTitle() async throws -> GetNavigationTitleResponse {
return try await navigationTitle().get()
return try await driver.getNavigationTitle()
}

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
Expand Down
Loading

0 comments on commit 511d222

Please sign in to comment.