rod: Can't access iframe on some websites
Rod Version: v0.102.0
The code to demonstrate your question
package main
import (
"github.com/go-rod/rod"
"github.com/go-rod/rod/lib/defaults"
)
func main() {
defaults.Show = true
page := rod.New().MustConnect().NoDefaultDevice().MustPage("https://captcha.website")
f := page.MustElement("div:not([style*='display:']) > iframe[data-hcaptcha-widget-id]").MustFrame()
f.MustElement("#checkbox")
}
The code above will panic. It works fine on headless mode.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 17
Commits related to this issue
- 修复 rod 在获取 iframe 后操作的问题 see https://github.com/go-rod/rod/issues/548 Signed-off-by: allan716 <525223688@qq.com> — committed to ChineseSubFinder/ChineseSubFinder by allanpk716 2 years ago
A temp solution is to use
PageFromTargetIDto create a standalone page for the iframe:I will take some time to redesign how the js runtime works to completely resolve this issue.
A temp solution is to download an older version of Chromium and replace the current version of Chromium. I successfuly tested my code with on version 884014
Any update on this?
Your temp solution didn’t work on it me.
I’m getting “Command can only be executed on top-level targets” error when PageFromTarget(proto.TargetTargetID(f.FrameID)) which f is what I got from calling el.Frame(). Wondering is this a same issue? then why the error is so different? BTW, no success with other suggested solutions (not tried old Chromium version though as I don’t see it as a sustainable solution). FYI, I’m trying to create a test that needs filling credit card information in Stripe iframe form.
@tlopo I have opened an issue on puppeteer, but no update yet