// MouseClickNode is an action that dispatches a mouse left button click event
// at the center of a specified node.
//
// Note that the window will be scrolled if the node is not within the window's
// viewport.
MouseClickNode is an action that dispatches a mouse left button click event
at the center of a specified node.

Note that the window will be scrolled if the node is not within the window's
viewport.
// MouseClickNode is an action that dispatches a mouse left button click event // at the center of a specified node . // // Note that the window will be scrolled if the node is not within the window ' s // viewport .
func MouseClickNode(n *cdp.Node, opts ...MouseOption) MouseAction {
	return ActionFunc(func(ctx context.Context) error {
		t := cdp.ExecutorFromContext(ctx).(*Target)
		if t == nil {
			return ErrInvalidTarget
		}
		frameID := t.enclosingFrame(n)
		t.frameMu.RLock()
		execCtx := t.execContexts[frameID]
		t.frameMu.RUnlock()
		var pos []float64
		err := evalInCtx(ctx, execCtx, snippet(scrollIntoViewJS, cashX(true), nil, n), &pos)
		if err != nil {
			return err
		}
		boxes, err := dom.GetContentQuads().WithNodeID(n.NodeID).Do(ctx)
		if err != nil {
			return err
		}
		content := boxes[0]
		c := len(content)
		if c%2 != 0 || c < 1 {
			return ErrInvalidDimensions
		}
		var x, y float64
		for i := 0; i < c; i += 2 {
			x += content[i]
			y += content[i+1]
		}
		x /= float64(c / 2)
		y /= float64(c / 2)
		return MouseClickXY(x, y, opts...).Do(ctx)
	})
}
func MouseClickNode ( n * cdp . Node , opts ... MouseOption ) MouseAction { return ActionFunc ( func ( ctx context . Context ) error { t := cdp . ExecutorFromContext ( ctx ) . ( * Target ) if t == nil { return ErrInvalidTarget } frameID := t . enclosingFrame ( n ) t . frameMu . RLock ( ) execCtx := t . execContexts [ frameID ] t . frameMu . RUnlock ( ) var pos [ ] float64 err := evalInCtx ( ctx , execCtx , snippet ( scrollIntoViewJS , cashX ( true ) , nil , n ) , & pos ) if err != nil { return err } boxes , err := dom . GetContentQuads ( ) . WithNodeID ( n . NodeID ) . Do ( ctx ) if err != nil { return err } content := boxes [ 0 ] c := len ( content ) if c % 2 != 0 || c < 1 { return ErrInvalidDimensions } var x , y float64 for i := 0 ; i < c ; i += 2 { x += content [ i ] y += content [ i + 1 ] } x /= float64 ( c / 2 ) y /= float64 ( c / 2 ) return MouseClickXY ( x , y , opts ... ) . Do ( ctx ) } ) }
MouseClickNode is an action that dispatches a mouse left button click event
at the center of a specified node.
MouseClickNode is an action that dispatches a mouse left button click event at the center of a specified node .