chromedp / pdlgen Goto Github PK
View Code? Open in Web Editor NEWGenerates templated code using Chrome DevTools PDL definitions.
License: MIT License
Generates templated code using Chrome DevTools PDL definitions.
License: MIT License
panic: could not resolve type cdp.compatibilitymode in domain cdp
goroutine 1 [running]:
github.com/chromedp/cdproto-gen/gen/gotpl.ResolveRef(0xc00419b2b8, 0xc00183fe60, {0xc0047d7c00, 0x2d, 0xc00419b258})
github.com/chromedp/cdproto-gen/gen/gotpl/util.go:143 +0x25d
github.com/chromedp/cdproto-gen/gen/gotpl.ResolveType(0xc004542b89, 0xc00183fe60, {0xc0047d7c00, 0x14034c6, 0xc000050900})
github.com/chromedp/cdproto-gen/gen/gotpl/util.go:160 +0x1ff
What versions are you running?
$ go list -m github.com/chromedp/chromedp
$ google-chrome --version
$ go version
github.com/chromedp/chromedp
Version 77.0.3865.90
go version go1.12.7 darwin/amd64
What did you do? Include clear steps.
I'm trying to implement the mouseWheel event,
p := input.DispatchMouseEvent(input.MouseWheel, 0, 0)
p = p.WithDeltaX(0)
p = p.WithDeltaY(float64(y))
err = p.Do(ctx)
without scrolling along the x-axis p.WithDeltaX(0).
What did you expect to see?
MouseWheel event triggered and webpage scrolls to y, without scrolling x.
What did you see instead?
Error 'deltaX' and 'deltaY' are expected for mouseWheel event (-32602)
Confusion?
Can we not scroll y without x?
type DispatchMouseEventParams struct {
Type MouseType `json:"type"` // Type of the mouse event.
X float64 `json:"x"` // X coordinate of the event relative to the main frame's viewport in CSS pixels.
Y float64 `json:"y"` // Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport.
Modifiers Modifier `json:"modifiers"` // Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0).
Timestamp *TimeSinceEpoch `json:"timestamp,omitempty"` // Time at which the event occurred.
Button ButtonType `json:"button,omitempty"` // Mouse button (default: "none").
Buttons int64 `json:"buttons,omitempty"` // A number indicating which buttons are pressed on the mouse when a mouse event is triggered. Left=1, Right=2, Middle=4, Back=8, Forward=16, None=0.
ClickCount int64 `json:"clickCount,omitempty"` // Number of times the mouse button was clicked (default: 0).
DeltaX float64 `json:"deltaX,omitempty"` // X delta in CSS pixels for mouse wheel event (default: 0).
DeltaY float64 `json:"deltaY,omitempty"` // Y delta in CSS pixels for mouse wheel event (default: 0).
PointerType DispatchMouseEventPointerType `json:"pointerType,omitempty"` // Pointer type (default: "mouse").
}
During the encoding they are ignored, not sure if this is the part causing the error?
if in.DeltaX != 0 {
const prefix string = ",\"deltaX\":"
out.RawString(prefix)
out.Float64(float64(in.DeltaX))
}
if in.DeltaY != 0 {
const prefix string = ",\"deltaY\":"
out.RawString(prefix)
out.Float64(float64(in.DeltaY))
}
follow code will panic:
package main
import (
"github.com/chromedp/cdproto/network"
"encoding/json"
)
func main() {
b,err:=json.Marshal(&network.Cookie{})
if err!=nil{
panic(err)
}
var c *network.Cookie
err=json.Unmarshal(b,&c)
if err!=nil{
panic(err)
}
return
}
same issue from chromedp/cdproto#7
It seems that the time should multiply time.Millisecond (1e6) rather than time.Second (1e9)
The corresponding code in cdproto are https://github.com/chromedp/cdproto/blob/8501c74e8228308e0dbd4aedb1f24ea1c103dd6e/network/types.go#LL1027
and
https://github.com/chromedp/cdproto/blob/8501c74e8228308e0dbd4aedb1f24ea1c103dd6e/cdp/types.go#L742
The following code snapshot is what I tried
package main
import (
"fmt"
"time"
)
func main() {
// a response time from cdp log
t := 1.685446691349539e+12
// correct time 2023-05-30 19:38:11.349539072 +0800 CST
fmt.Println(time.Unix(0, int64(t*float64(time.Millisecond))))
// wrong time 1677-09-21 08:12:43.145224192 +0800 CST
fmt.Println(time.Unix(0, int64(t*float64(time.Second))))
}
The URL to download these files (as in the README and found from other sources) is no longer valid. Do you know an updated URL?
Hi! This might ultimately be an easyjson bug, but running go vet on the generated cdproto package showed issues of mutex copies in the cdp sub-package.
Seen on latest master bfeac1f
$ go vet ./...
# github.com/chromedp/cdproto/cdp
cdp/easyjson.go:353:81: easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp1 passes lock by value: github.com/chromedp/cdproto/cdp.Node
cdp/easyjson.go:562:9: MarshalJSON passes lock by value: github.com/chromedp/cdproto/cdp.Node
cdp/easyjson.go:564:57: call of easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp1 copies lock value: github.com/chromedp/cdproto/cdp.Node
cdp/easyjson.go:569:9: MarshalEasyJSON passes lock by value: github.com/chromedp/cdproto/cdp.Node
cdp/easyjson.go:570:56: call of easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp1 copies lock value: github.com/chromedp/cdproto/cdp.Node
cdp/easyjson.go:631:81: easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp2 passes lock by value: github.com/chromedp/cdproto/cdp.Frame
cdp/easyjson.go:684:9: MarshalJSON passes lock by value: github.com/chromedp/cdproto/cdp.Frame
cdp/easyjson.go:686:57: call of easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp2 copies lock value: github.com/chromedp/cdproto/cdp.Frame
cdp/easyjson.go:691:9: MarshalEasyJSON passes lock by value: github.com/chromedp/cdproto/cdp.Frame
cdp/easyjson.go:692:56: call of easyjsonC5a4559bEncodeGithubComChromedpCdprotoCdp2 copies lock value: github.com/chromedp/cdproto/cdp.Frame
I'm new to this project and don't quite understand how all the code is generated, but I'm happy keep digging if it's not a straight forward fix.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.