-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Brief summary
Hi, I have been trying to set a pipeline to automatically run our k6 browser tests in order to collect periodically some web vital metrics.
The problem is that I can't manage to make it work because I'm getting panic: runtime error: invalid memory address or nil pointer dereference
. I have been trying to look out for solutions or even if this was reported before and I haven't found anything. So I'm kindly requesting your support here.
The k6 version run within the jenkins job returns
k6 v0.46.0 (2023-08-14T13:23:26+0000/v0.46.0-0-gcbd9e9ad, go1.20.7, linux/amd64)
let me proceed to explain what I see
k6 version
k6 v0.46.0 (2023-08-14T13:23:26+0000/v0.46.0-0-gcbd9e9ad, go1.20.7, linux/amd64)
OS
linux
Docker version and image (if applicable)
No response
Steps to reproduce the problem
I have two examples,
one of them triggers the panic: runtime error
. However, when I execute the example script described in k6.io, this one works perfectly fine.
The following script triggers the panic
import { browser } from 'k6/experimental/browser';
import { check } from 'k6';
export let options = {
scenarios: {
addProductToCart: {
executor: 'shared-iterations',
iterations: 10,
vus: 1,
options: {
browser: {
type: 'chromium',
},
},
},
}
};
export default async function () {
const context = browser.newContext();
try {
context.addCookies([{name: COOKIE_NAME, value: COOKIE_VALUE, domain: COOKIE_DOMAIN, path: "/"}]);
const page = context.newPage();
await page.goto(url, { waitUntil: 'networkidle' });
await page.locator(loc1).click();
await page.locator(loc2).click();
await page.locator(loc3).click();
page.locator(loc4).waitFor({ state: 'visible' });
check(page, {
'Item is added to cart': page.locator(loc5).textContent() == 'validation text'
}
);
} finally {
page.close();
}
}
The following script doesn't trigger the panic
import { browser } from 'k6/experimental/browser';
export let options = {
scenarios: {
example: {
executor: 'shared-iterations',
iterations: 10,
vus: 1,
options: {
browser: {
type: 'chromium',
},
},
},
}
};
export default async function () {
const page = browser.newPage();
try {
await page.goto('https://test.k6.io/');
} finally {
page.close();
}
}
Expected behaviour
Script is executed succesfully
Actual behaviour
When I execute the file provided above, I face the following output
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x1195471]
goroutine 1000 [running]:
github.com/grafana/xk6-browser/common.(*ElementHandle).clickablePoint(0xc00068d9f0)
github.com/grafana/xk6-browser@v1.0.2/common/element_handle.go:181 +0x2d1
github.com/grafana/xk6-browser/common.(*ElementHandle).newPointerAction.func1({0x1a09cb0, 0xc000ae8ae0}, 0x0?)
github.com/grafana/xk6-browser@v1.0.2/common/element_handle.go:1441 +0x3ba
github.com/grafana/xk6-browser/common.retryPointerAction({0x1a09cb0, 0xc000ae8ae0}, 0xc001f78b80, 0xc0023d6240)
github.com/grafana/xk6-browser@v1.0.2/common/element_handle.go:1488 +0x42
github.com/grafana/xk6-browser/common.(*ElementHandle).newPointerAction.func2({0x1a09cb0?, 0xc000ae8ae0?}, 0xc0023d6240?, 0x0?)
github.com/grafana/xk6-browser@v1.0.2/common/element_handle.go:1476 +0x3b
github.com/grafana/xk6-browser/common.(*Frame).newPointerAction.func1({0x1a09cb0, 0xc000ae8ae0}, 0xc0007f2ea0, 0xc0007f2f00)
github.com/grafana/xk6-browser@v1.0.2/common/frame.go:1989 +0x169
created by github.com/grafana/xk6-browser/common.call
github.com/grafana/xk6-browser@v1.0.2/common/helpers.go:102 +0x17b
script returned exit code 2