I can only see a way to do this using JavaScript, inject the following in to the page, making changes where needed:
// Get a reference to the button element needing to be clicked
var button = document.querySelector("button");
// Use the following function:
navigateToPage(button, "page");
// Link to page with query string of `?page=[n]` (see URL),
// then click the specified element n times
function navigateToPage(button, queryParamName) {
var times = parseInt(getQueryVariable(queryParamName), 10);
for (var i = 0; i < times; i++) {
button.click();
}
}
// Taken from: https://stackoverflow.com/questions/2090551/parse-query-string-in-javascript
// ----
// If you don't need to support IE 11, see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/get
// for a more native solution to fetch query params.
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
return variable;
}
See the following Codesandbox for a live example:
https://codesandbox.io/s/ox0k1y16k6
Watch how many times the button is clicked based off the query parameter in the URL:
https://ox0k1y16k6.codesandbox.io/?page=3
https://ox0k1y16k6.codesandbox.io/?page=10