File tree 4 files changed +18
-10
lines changed
4 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -350,15 +350,15 @@ public enum Requests {
350
350
// https://www.selenium.dev/documentation/legacy/json_wire_protocol/#sessionsessionidtimeouts
351
351
public struct SessionTimeouts : Request {
352
352
public var session : String
353
- public var type : String
353
+ public var type : TimeoutType
354
354
public var ms : Double
355
355
356
356
public var pathComponents : [ String ] { [ " session " , session, " timeouts " ] }
357
357
public var method : HTTPMethod { . post }
358
358
public var body : Body { . init( type: type, ms: ms) }
359
359
360
360
public struct Body : Codable {
361
- public var type : String
361
+ public var type : TimeoutType
362
362
public var ms : Double
363
363
}
364
364
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public class Session {
34
34
if newValue == _implicitWaitTimeout { return }
35
35
if !emulateImplicitWait {
36
36
do {
37
- try setTimeout ( type: TimeoutType . implicitWait, duration: newValue)
37
+ try setTimeout ( type: . implicitWait, duration: newValue)
38
38
} catch {
39
39
emulateImplicitWait = true
40
40
}
@@ -101,11 +101,11 @@ public class Session {
101
101
}
102
102
103
103
/// Sets a a timeout value on this session.
104
- public func setTimeout( type: String , duration: TimeInterval ) throws {
104
+ public func setTimeout( type: TimeoutType , duration: TimeInterval ) throws {
105
105
try webDriver. send (
106
106
Requests . SessionTimeouts ( session: id, type: type, ms: duration * 1000 ) )
107
107
// Keep track of the implicit wait to know when we need to override it.
108
- if type == TimeoutType . implicitWait { _implicitWaitTimeout = duration }
108
+ if type == . implicitWait { _implicitWaitTimeout = duration }
109
109
}
110
110
111
111
public func execute( script: String , args: [ String ] = [ ] , async : Bool = false ) throws {
Original file line number Diff line number Diff line change 1
- public enum TimeoutType {
2
- public static let script = " script "
3
- public static let implicitWait = " implicit "
4
- public static let pageLoad = " page load "
5
- }
1
+ public enum TimeoutType : String , Codable {
2
+ case script
3
+ case implicitWait = " implicit "
4
+ case pageLoad = " page load "
5
+ }
Original file line number Diff line number Diff line change @@ -330,4 +330,12 @@ class APIToRequestMappingTests: XCTestCase {
330
330
}
331
331
XCTAssert ( try session. source == " currentSource " )
332
332
}
333
+
334
+ func testSessionTimeouts( ) throws {
335
+ let mockWebDriver : MockWebDriver = MockWebDriver ( )
336
+ let session = Session ( webDriver: mockWebDriver, existingId: " mySession " )
337
+ mockWebDriver. expect ( path: " session/mySession/timeouts " , method: . post)
338
+ try session. setTimeout ( type: . implicitWait, duration: 5 )
339
+ XCTAssert ( session. implicitWaitTimeout == 5.0 )
340
+ }
333
341
}
You can’t perform that action at this time.
0 commit comments