【发布时间】:2020-04-19 13:54:19
【问题描述】:
我实际上试图在golang chromedp 中执行这段代码,但没有工作
const inlineJavascript = `
var textarea = document.createElement('textarea');
textarea.setAttribute('id', 'recaptcha-token-container');
textarea.style.display = 'display:none;'
document.body.appendChild(textarea);
grecaptcha.execute('SITE_KEY', { action: 'login' }).then(function(token) {
textarea.value = token;
textarea.style.display = ''
});
`
chromedp.EvaluateAsDevTools(inlineJavascript, &token),
chromedp.WaitVisible(`#recaptcha-token-container`),
chromedp.Value(`#recaptcha-token-container`, &token),
应用程序等待 textarea,.then 不工作并且 textarea never 正在显示。
【问题讨论】:
-
我假设 SITE_KEY 设置正确。当您将 sn-p 粘贴到浏览器的开发工具中时,它是否有效?您可能还想处理错误并将它们显示在您可以看到的地方
-
@xarantolus
SITE_KEY已修改,是的,在 devtools 中工作正常,但返回。 -
log.Println(token)返回map[then:map[]]
标签: go promise webdriver chromedp