forked from playwright-community/playwright-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
artifact.go
58 lines (49 loc) · 1.36 KB
/
artifact.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
48
49
50
51
52
53
54
55
56
57
58
package playwright
import "errors"
type artifactImpl struct {
channelOwner
}
func (a *artifactImpl) AbsolutePath() string {
return a.initializer["absolutePath"].(string)
}
func (a *artifactImpl) PathAfterFinished() (string, error) {
if a.connection.isRemote {
return "", errors.New("Path is not available when connecting remotely. Use SaveAs() to save a local copy")
}
path, err := a.channel.Send("pathAfterFinished")
return path.(string), err
}
func (a *artifactImpl) SaveAs(path string) error {
if !a.connection.isRemote {
_, err := a.channel.Send("saveAs", map[string]interface{}{
"path": path,
})
return err
}
streamChannel, err := a.channel.Send("saveAsStream")
if err != nil {
return err
}
stream := streamChannel.(*streamImpl)
return stream.SaveAs(path)
}
func (d *artifactImpl) Failure() (string, error) {
failure, err := d.channel.Send("failure")
if failure == nil {
return "", err
}
return failure.(string), err
}
func (d *artifactImpl) Delete() error {
_, err := d.channel.Send("delete")
return err
}
func (d *artifactImpl) Cancel() error {
_, err := d.channel.Send("cancel")
return err
}
func newArtifact(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *artifactImpl {
artifact := &artifactImpl{}
artifact.createChannelOwner(artifact, parent, objectType, guid, initializer)
return artifact
}