From a2dc2585edf7b3ab11254faafd82b50f6e563af9 Mon Sep 17 00:00:00 2001 From: ankur22 Date: Thu, 16 Nov 2023 15:11:39 +0000 Subject: [PATCH] fixup! Update mapping to avoid mapping nil elementHandle --- browser/mapping.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/browser/mapping.go b/browser/mapping.go index 21c442d23..02d235aea 100644 --- a/browser/mapping.go +++ b/browser/mapping.go @@ -253,6 +253,9 @@ func mapElementHandle(vu moduleVU, eh *common.ElementHandle) mapping { if err != nil { return nil, err //nolint:wrapcheck } + // ElementHandle can be null when the selector does not match any elements. + // We do not want to map nil elementHandles since the expectation is a + // null result in the test script for this case. if eh == nil { return nil, nil //nolint:nilnil } @@ -399,6 +402,9 @@ func mapFrame(vu moduleVU, f *common.Frame) mapping { if err != nil { return nil, err //nolint:wrapcheck } + // ElementHandle can be null when the selector does not match any elements. + // We do not want to map nil elementHandles since the expectation is a + // null result in the test script for this case. if eh == nil { return nil, nil //nolint:nilnil } @@ -600,6 +606,9 @@ func mapPage(vu moduleVU, p *common.Page) mapping { if err != nil { return nil, err //nolint:wrapcheck } + // ElementHandle can be null when the selector does not match any elements. + // We do not want to map nil elementHandles since the expectation is a + // null result in the test script for this case. if eh == nil { return nil, nil //nolint:nilnil }