Right click on element using k6 browser

Hi Team,

Is there any other way to do a right click on text element ?

Used line of code :

const element = page.locator(‘id_here’);
await element.click({button:‘right’});

Above line of code is making a default left click on the element.

Hi, the code seems right, and it should work. For example:

const element = page.locator('#id_here'); // <- mind the sharp (#)
await element.click({button:'right'});

Also, make sure that you’re using single-quotes (like this: ').

1 Like

Thanks for your reply!

I am running the k6 code in headless mode and I could see that the text element is getting clicked (left click) but right click is not happening.

Sure. I’ve tested this locally, and it works. Maybe there’s an edge case we don’t handle. Could you share your script?

image

Sorry, I can’t share the script. But the scenario looks similar to the above image. One text element is there and on right click, a menu appears & from that menu I need to select the first option. sample HTML code

Hi @betsybenny2000,

I can’t reproduce this problem. Please send me a private forum message (containing your script) if it’s possible.

Thank you.