MCPcopy
hub / github.com/mxschmitt/playwright-go / StorageState

Method StorageState

fetch.go:337–366  ·  view source on GitHub ↗
(options ...APIRequestContextStorageStateOptions)

Source from the content-addressed store, hash-verified

335}
336
337func (r *apiRequestContextImpl) StorageState(options ...APIRequestContextStorageStateOptions) (*StorageState, error) {
338 params := map[string]any{}
339 var path *string
340 if len(options) == 1 {
341 params["indexedDB"] = options[0].IndexedDB
342 path = options[0].Path
343 }
344 result, err := r.channel.SendReturnAsDict("storageState", params)
345 if err != nil {
346 return nil, err
347 }
348 if path != nil {
349 if err := os.MkdirAll(filepath.Dir(*path), 0o777); err != nil {
350 return nil, err
351 }
352 file, err := os.Create(*path)
353 if err != nil {
354 return nil, err
355 }
356 if err := json.NewEncoder(file).Encode(result); err != nil {
357 return nil, err
358 }
359 if err := file.Close(); err != nil {
360 return nil, err
361 }
362 }
363 var storageState StorageState
364 remapMapToStruct(result, &storageState)
365 return &storageState, nil
366}
367
368func (r *apiRequestContextImpl) Tracing() Tracing {
369 return r.tracing

Callers

nothing calls this directly

Calls 4

remapMapToStructFunction · 0.85
SendReturnAsDictMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected