From 43ec86f847645e6925cf4bc0da398327c82a5f16 Mon Sep 17 00:00:00 2001 From: johlanse Date: Thu, 24 Feb 2022 14:15:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=AF=8F?= =?UTF-8?q?=E5=91=A8=E7=AD=94=E9=A2=98=E7=82=B9=E5=87=BB=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/respond.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/respond.go b/lib/respond.go index 8ec0425..02d3eb3 100644 --- a/lib/respond.go +++ b/lib/respond.go @@ -345,6 +345,7 @@ func getAnswerPage(page playwright.Page, model string) bool { if err1 != nil { log.Errorln("点击页码失败") } + time.Sleep(2 * time.Second) datas, err := page.QuerySelectorAll(modelSlector) if err != nil { log.Errorln("获取页面内容失败") @@ -353,6 +354,7 @@ func getAnswerPage(page playwright.Page, model string) bool { for _, data := range datas { content, err := data.TextContent() if err != nil { + log.Errorln("获取按钮文本失败" + err.Error()) continue } if strings.Contains(content, "重新") || strings.Contains(content, "满分") { @@ -369,6 +371,8 @@ func getAnswerPage(page playwright.Page, model string) bool { if enabled { log.Infoln("按钮可用") } + data.WaitForElementState("stable", playwright.ElementHandleWaitForElementStateOptions{Timeout: playwright.Float(10000)}) + time.Sleep(5 * time.Second) err = data.Click(playwright.ElementHandleClickOptions{ Button: nil, ClickCount: playwright.Int(2),