...

Source file src/github.com/playwright-community/playwright-go/artifact.go

Documentation: github.com/playwright-community/playwright-go

     1  package playwright
     2  
     3  import "errors"
     4  
     5  type artifactImpl struct {
     6  	channelOwner
     7  }
     8  
     9  func (a *artifactImpl) AbsolutePath() string {
    10  	return a.initializer["absolutePath"].(string)
    11  }
    12  
    13  func (a *artifactImpl) PathAfterFinished() (string, error) {
    14  	if a.connection.isRemote {
    15  		return "", errors.New("Path is not available when connecting remotely. Use SaveAs() to save a local copy")
    16  	}
    17  	path, err := a.channel.Send("pathAfterFinished")
    18  	return path.(string), err
    19  }
    20  
    21  func (a *artifactImpl) SaveAs(path string) error {
    22  	if !a.connection.isRemote {
    23  		_, err := a.channel.Send("saveAs", map[string]interface{}{
    24  			"path": path,
    25  		})
    26  		return err
    27  	}
    28  	streamChannel, err := a.channel.Send("saveAsStream")
    29  	if err != nil {
    30  		return err
    31  	}
    32  	stream := streamChannel.(*streamImpl)
    33  	return stream.SaveAs(path)
    34  }
    35  
    36  func (d *artifactImpl) Failure() (string, error) {
    37  	failure, err := d.channel.Send("failure")
    38  	if failure == nil {
    39  		return "", err
    40  	}
    41  	return failure.(string), err
    42  }
    43  
    44  func (d *artifactImpl) Delete() error {
    45  	_, err := d.channel.Send("delete")
    46  	return err
    47  }
    48  
    49  func (d *artifactImpl) Cancel() error {
    50  	_, err := d.channel.Send("cancel")
    51  	return err
    52  }
    53  
    54  func newArtifact(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *artifactImpl {
    55  	artifact := &artifactImpl{}
    56  	artifact.createChannelOwner(artifact, parent, objectType, guid, initializer)
    57  	return artifact
    58  }
    59  

View as plain text