Echape
December 22, 2021, 12:11pm
1
Hello There!
I am new to k6 and am really enjoying it.
However, I discovered xk6-browser and tried to use it for a project but couldn’t navigate to url.
After installing xk6-browser and chrome executable, I ran the code :
const browser = launcher.launch('chromium', { headless: false });
const context = browser.newContext({ignoreHTTPSErrors: false });
const page = context.newPage();
page.goto('https://www.halopedia.org/Through_the_Trees');
The output looks like this :
I just don’t understand what’s wrong… Any idea about what’s going on here, please ??
Hi Echape,
It’s a known problem, and we’re working on fixing it. You can follow the issue for updates here .
By the way, is the script you shared the whole script? It’s because I can run this script without a problem locally. For example, I don’t see a problem with the following script locally:
import launcher from 'k6/x/browser';
import { check } from 'k6';
export default function() {
const browser = launcher.launch('chromium', { headless: false });
const context = browser.newContext({ignoreHTTPSErrors: false });
let page = context.newPage();
page.goto('https://www.halopedia.org/Through_the_Trees', { waitUntil: 'networkidle' });
let c = page.$('p.subtitle');
console.log(c.innerHTML());
page.close();
browser.close();
}
I also wonder about the Chrome version you’re using. Can you run the script by adding the following as a prefix to the k6
command and share the log with us?
XK6_BROWSER_DEBUG=trace k6 run yourScriptPath.js
Thanks.
1 Like
Echape
December 22, 2021, 2:43pm
4
Hi inanc, thanks for replying !
I scraped a part of the code to be more readable, but here’s the full script :
import launcher from 'k6/x/browser';
import { sleep, check } from 'k6';
export let options = {
stages : [{ duration: '10s', target: 1 },
{ duration: '10s', target: 1 },
{ duration: '10s', target: 0 }]
};
export default function(){
var t0, t1;
console.log("Begin");
t0 = Date.now();
const browser = launcher.launch('chromium', { headless: false });
t1 = Date.now();
console.log("Launch done : " + (t1 - t0).toFixed(3));
t0 = Date.now();
const context = browser.newContext({
ignoreHTTPSErrors: false // Ignore HTTPS certificate issues
});
t1 = Date.now();
console.log("Context done : " + (t1 - t0).toFixed(3));
t0 = Date.now();
const page = context.newPage();
t1 = Date.now();
console.log("Page created : " + (t1 - t0).toFixed(3));
t0 = Date.now();
page.goto('https://www.halopedia.org/Through_the_Trees');
t1 = Date.now();
console.log("URL navigated : " + (t1 - t0).toFixed(3));
sleep(7);
// page.mouse.wheel(0, 50);
/*console.log("//////////////////////");
for (var entry in page.mouse){
console.log(entry);
console.log(page.mouse[entry]);
}*/
console.log("//////////////////////");
console.log("Mouse Scrolled !!!")
// sleep(20);
/*page.mouse.move(994, 49);
page.mouse.down();
page.mouse.up();
sleep(1);*/
t0 = Date.now();
page.screenshot({ path: `./H2H.png` });
t1 = Date.now();
console.log("Screenshot taken : " + (t1 - t0).toFixed(3));
browser.close();
console.log("end");
}
I also tried to run the script you shared, but got the following errors :
However, this script ends properly.
As for the google chrome version , I use the V. 96.0.4664.110 , on CentOs 7.
NB : Just want to point out that I’m running the script within a VM, within an intranet behind a proxy. But the domain to reach can be pinged
2 Likes
Hi Echape,
Thanks for sharing the whole script, it helped me to fix a few more bugs
It seems we fixed the problem and publish it in the next release.
1 Like
Echape
December 23, 2021, 2:23pm
7
Glad to hear it !
Then I can’t wait to try the next version.
Do you have any idea about when it comes out ?
2 Likes
I’m expecting it in two weeks or so.
1 Like
Echape
December 23, 2021, 4:18pm
9
Nice! See you in 2 weeks to make it work
Thanks for your help, merry christmas and happy new year
Echape
1 Like
Yeah, sure, let’s talk in 2 weeks. Happy new year and merry Christmas
2 Likes
Hi @Echape ,
We released a new xk6-browser version, here . Please feel free to try it and tell us your findings.
Thanks!
1 Like