-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscena.go
47 lines (40 loc) · 976 Bytes
/
scena.go
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
package main
import (
"log"
"github.com/fedesog/webdriver"
)
type OsInfo struct {
driver string
osname string
}
type Connection struct {
name string
drv *webdriver.ChromeDriver
sess *webdriver.Session
}
type Scenario struct {
name string
apply func(*webdriver.Session)
}
func initConnection(name string) Connection {
driver := webdriver.NewChromeDriver(osinfo.driver)
if err := driver.Start(); err != nil {
log.Panic(err)
}
desired := webdriver.Capabilities{"Platform": osinfo.osname}
required := webdriver.Capabilities{}
session, err := driver.NewSession(desired, required)
if err != nil {
log.Panic(err)
}
return Connection{name, driver, session}
}
func worker(id int, scenarios <-chan Scenario) {
for scenario := range scenarios {
log.Println("worker", id, "started:", scenario.name)
conn := initConnection(scenario.name)
scenario.apply(conn.sess)
connectionsChan <- conn
log.Println("worker", id, "finished:", scenario.name)
}
}