mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 12:07:09 +00:00
feat(driver): add Snapshot to chrome and mock drivers
The chrome tab is single-threaded so its Snapshot pairs the two reads without extra locking. The mock records ActionSnapshot so tests can assert the runner reaches for the paired RPC.
This commit is contained in:
1 parent
c11beb1728
commit
c57be03b69
2 files changed
+30
No files matched your search
@@ -268,6 +268,21 @@ func (d *Driver) Screenshot(_ context.Context) (driver.Image, error) {
|
||||
return driver.Image{PNG: buf, Width: w, Height: h}, nil
|
||||
}
|
||||
|
||||
// Snapshot pairs hierarchy and screenshot back-to-back. The chromedp tab
|
||||
// is single-threaded so the two CDP round-trips are already serialized:
|
||||
// pairing them here matches the DeviceDriver contract without extra locking.
|
||||
func (d *Driver) Snapshot(ctx context.Context) (string, driver.Image, error) {
|
||||
hierarchy, err := d.Hierarchy(ctx)
|
||||
if err != nil {
|
||||
return "", driver.Image{}, err
|
||||
}
|
||||
image, err := d.Screenshot(ctx)
|
||||
if err != nil {
|
||||
return hierarchy, driver.Image{}, err
|
||||
}
|
||||
return hierarchy, image, nil
|
||||
}
|
||||
|
||||
func (d *Driver) RecentLogs(_ context.Context, since time.Time, minLevel string) ([]driver.LogEntry, error) {
|
||||
sinceMillis := since.UnixMilli()
|
||||
d.logsMu.Lock()
|
||||
|
||||
Reference in new issue
Block a user