-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathsession.go
More file actions
52 lines (45 loc) · 1006 Bytes
/
session.go
File metadata and controls
52 lines (45 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package webdriver
import (
"github.com/tebeka/selenium"
"github.com/viant/endly"
)
// Session represents a selenium session
type Session struct {
SessionID string
Browser string
Pid int
Server string
Remote string
Capture *CaptureState
Net *netTracker
driver selenium.WebDriver
service *selenium.Service
Capabilities []string
}
func (s Session) Driver() selenium.WebDriver {
return s.driver
}
func (s Session) Close() {
if s.driver != nil {
s.driver.Quit()
}
if s.service != nil {
s.service.Stop()
}
}
// SeleniumSessions reprents selenium sessions.
type sessions struct {
Sessions map[string]*Session
}
var sessionKey = (*sessions)(nil)
func Sessions(context *endly.Context) map[string]*Session {
var result *sessions
if !context.Contains(sessionKey) {
result = &sessions{
Sessions: make(map[string]*Session),
}
context.Put(sessionKey, result)
}
context.GetInto(sessionKey, &result)
return result.Sessions
}