Closed BeyondIM closed 6 months ago
Rod Version: v0.114.8
func TestRod(t *testing.T) { _, err := page.Element("[id^='postmessage_'] .locked") if err == nil { page.MustElement("[id^='postmessage_'] .locked a").MustClick() postCommentBtn := page.MustElement("#fwin_reply button[type='submit']") postCommentBtn.MustWaitStable() page.MustElement("#fwin_reply #postmessage").MustInput("感谢分享") postCommentBtn.MustClick().MustWaitInvisible() } slog.Info("debug", "111", "111") }
存在的问题是,如果页面存在 [id^='postmessage_'] .locked,那么代码执行没有问题,如果不存在,则 slog.Info("debug", "111", "111") 不会执行,很奇怪
[id^='postmessage_'] .locked
slog.Info("debug", "111", "111")
请仔细阅读 page.Element 的文档
page.Element
https://github.com/go-rod/rod/blob/0340433eab4e6551f075eaf1875035469a777480/query.go#L140-L142
Rod Version: v0.114.8
存在的问题是,如果页面存在
[id^='postmessage_'] .locked
,那么代码执行没有问题,如果不存在,则slog.Info("debug", "111", "111")
不会执行,很奇怪