I’m testing completed checkouts on a WooCommerce powered website (you can visit the example website by reviewing the script, linked at the bottom).
Had difficulty getting k6 to target the embedded iframes of the Braintree checkouts section, but finally cleared that hurdle.
The problem is after interacting with those two iframes, and then clicking on the Place order button (outside of those iframes) the test crashes within a couple seconds of that. I’ve tested different orders of operation to isolate exactly when the crash is happening (right after the page.screenshot on line 186 of my script).
I feel like the issue is that k6 is losing the context of the main page itself because of the iframe interactions but I can’t figure out a way to get it to not crash.
Here is the panic:
panic: GoError: dispose: disposing element with ID -1220096293751216353.29.1: Cannot find context with specified id (-32000)
Can’t embed the full trace because it’s seeing all the github mentions as URLs and I’m only allowed to post two apparently.
I’ve tried your script and at the moment I can’t seem to get past line 169 (const iframeHandle2 = page.waitForSelector('iframe[id*="braintree-hosted-field-expirationDate"]');), and it eventually times out looking for that selector. Do you know of anything has changed on your site?
Yes, because we were completely stalled we had to switch back to doing only a COD checkout within WooCommerce. I have switched it back to Braintree so you should be able to retest. Thanks! Let me know if there is anything I can do to help.
Ok, now it’s progressed to line 162 (const field1 = frame.waitForSelector("input[name='credit-card-number']");) but seems to be waiting indefinitely there (which isn’t good either).
Hi @ankur, I was waiting for these fixes, but still get similar error:
"panic: GoError: attaching iframe: attaching iframe target ID 336736BF1A0F9C59453A3471915510B1 to session ID B708E7301EF5DC72D9EDA91919296A0D: getting browser window ID: No web contents for the given target id (-32000)
goroutine 160 [running]:
go.k6.io/k6/js/common.Throw(...)
go.k6.io/k6/js/common/util.go:20
github.com/grafana/xk6-browser/k6ext.Panic.func1(0xc002574008, {0xc0022faaa0?, 0x1ba1198?, 0xc001b5e080?})
github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:35 +0x74
github.com/grafana/xk6-browser/k6ext.sharedPanic({0x1bbc2c8, 0xc000d4ae10}, 0xc00311dc80, {0xc0022faaa0, 0x2, 0x2})
github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:64 +0x274
github.com/grafana/xk6-browser/k6ext.Panic({0x1bbc2c8?, 0xc000d4ae10?}, {0x180287d?, 0x29c6b40?}, {0xc0022faaa0?, 0xc00311dd00?, 0xc00311de08?})
github.com/grafana/xk6-browser@v1.4.3/k6ext/panic.go:37 +0x5a
github.com/grafana/xk6-browser/common.(*FrameSession).onAttachedToTarget(0xc0014a7a20, 0xc0022fa4a0)
github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:955 +0x671
github.com/grafana/xk6-browser/common.(*FrameSession).initEvents.func1()
github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:279 +0x238
created by github.com/grafana/xk6-browser/common.(*FrameSession).initEvents in goroutine 148
github.com/grafana/xk6-browser@v1.4.3/common/frame_session.go:220 +0x19b`
I run the tests in github actions on image: grafana/k6:master-with-browser and with options: --rm -i -v ${{ github.workspace }}:/app -w /app --network host -e K6_BROWSER_ENABLED=true --user root
Hello @ankur, i see the same error with my k6-browser script. When i ran with headless=false it worked perfect. But in headless mode it’s throwing panic error (panic: GoError: attaching iframe: attaching iframe target ID 225D1C79A0FF66C9E9A4E80CC970216C to session ID E461CF6D2436F061CDF233903EC34485: getting browser window ID: No web contents for the given target id (-32000)rrupted iterations)
FYI, i’m using latest version of k6 (k6 v0.51.0 (go1.22.3, darwin/arm64)) which intern using xk6-browser@v1.5.1
@ankur I’m getting something similar on my end too. When running my test script in no-headless config everything works fine, but when running the test script in headless config this error halts test execution
panic: GoError: attaching iframe: attaching iframe target ID D1EEEDA5F1A09832DFA76BEDF0900053 to session ID 343164C61E5BFBE47C8129A6F3458395: getting browser window ID: No web contents for the given target id (-32000)