-
-
Notifications
You must be signed in to change notification settings - Fork 411
Description
Rod Version: v0.116.2
The code to demonstrate your question
package rod_test
import (
"testing"
"github.com/go-rod/rod/lib/proto"
)
// This is the template to demonstrate how to test Rod.
func TestRod(t *testing.T) {
g := setup(t)
g.cancelTimeout()
page := g.page
err := proto.AccessibilityEnable{}.Call(page)
if err != nil {
panic(err)
}
wait := page.EachEvent(
func(e *proto.AccessibilityLoadComplete) bool {
res, err := proto.AccessibilityGetPartialAXTree{
BackendNodeID: e.Root.BackendDOMNodeID,
FetchRelatives: false,
}.Call(page)
if err != nil {
panic(err)
}
g.Len(res.Nodes, 1)
return true
},
)
page.MustNavigate(g.html(doc)).MustWaitLoad()
wait()
}
const doc = `
<html>
<body>ok</body>
</html>
`
What you got
parallel test 12
=== RUN TestRod
=== PAUSE TestRod
=== CONT TestRod
rod_test.go:30: ⦗expect len⦘ 3 ⦗to be⦘ 1
--- FAIL: TestRod (0.73s)
FAIL
exit status 1
FAIL github.com/go-rod/rod 1.164s
What you expect to see
The CDP command Accessibility.getPartialAXTree
, should only return one node (the node with the given BackendDOMNodeID
) and not its relatives when fetchRelatives
is set to false
. This is not the case currently.
As of now, there is effectively no way to send the Accessibility.getPartialAXTree
(and other similar commands with optional boolean fields) with fetchRelatives
set to false
.
What have you tried to solve the question
Since the default value for fetchRelatives
if it is missing is true
and setting the field to false
will cause the field to be deleted because of json:..,omitempty
, the behavior of the command is incorrect.
The remedy for this specific case is to turn the type of the field from bool
to *bool
, similar to what you have already done with optional fields that have an int
type with a non-zero default value in other commands.
A PR that addresses this is linked here.