Is there any option to click a button element without loading a page

Hi team,
I have a scenario to click a button without page load and I have gone through posters-advanced-loadtest-suite and I found loadPageByClick, Is there any alternate option for clicking a button without page load?
Thanks In advance

You can just do an element.click() (part of the HtmlUnit API) but this usually does not do much because JS is normally off for load testing and/or the JS dialect of HtmlUnit is not sufficient to make modern webpages fly. If it loads a page, you have to take the loadPageBy methods to keep the context right. If the click does not run a page load, rather something with JavaScript, it is likely not to work correctly.

Please keep in mind, this is load testing, this is not functional testing. Running JS on the client (even the small JS of HtmlUnit) is likely resource consuming or incorrect (due to the version of JS).

What is your goal?

Thanks for the replay, Now i understood why element.click() not working its just because of JS is off.
So instead of clicking the button I am make a POST request with form-data and I have tried sending data using .parm(“Key”,“value”) not working so can you please help me how to make post request by sending form-data.
please find attached files for better understanding .
image

Thanks

There should be a method called postParam(key, value) at the XHR object. So use this instead of param(key, value) which appends that to the url.

By the way, depending on what you POST, you might not need the header definition. Multipart POST is a different beast and typically used for data uploads. I guess you rather do a form-encoded POST here.

thanks for your response and its Working fine with postParam(key, value) and some times it is getting failed, is there any wait for response method ?

thanks

This is not a functional test in the browser where you have to wait for something. When you fire the request, you get your result. Maybe I don’t get the problem. If the request fails, it fails… that is the purpose of your test :wink: