Navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times
I am using a slider in wordpress that does not include anchors to allow us to link to a specific section.
Is it possible to navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times with java or selenium.
We can anchor to a text block but how the split screen slider functions this does load the page correctly.
We are developing locally but here is the theme example. I am attempting to link to slide 3. http://tahoe.edge-themes.com/split-screen-slider/
Backend functionality is not my strong suit. Thank you.
javascript jquery selenium navigation keypress
add a comment |
I am using a slider in wordpress that does not include anchors to allow us to link to a specific section.
Is it possible to navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times with java or selenium.
We can anchor to a text block but how the split screen slider functions this does load the page correctly.
We are developing locally but here is the theme example. I am attempting to link to slide 3. http://tahoe.edge-themes.com/split-screen-slider/
Backend functionality is not my strong suit. Thank you.
javascript jquery selenium navigation keypress
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27
add a comment |
I am using a slider in wordpress that does not include anchors to allow us to link to a specific section.
Is it possible to navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times with java or selenium.
We can anchor to a text block but how the split screen slider functions this does load the page correctly.
We are developing locally but here is the theme example. I am attempting to link to slide 3. http://tahoe.edge-themes.com/split-screen-slider/
Backend functionality is not my strong suit. Thank you.
javascript jquery selenium navigation keypress
I am using a slider in wordpress that does not include anchors to allow us to link to a specific section.
Is it possible to navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times with java or selenium.
We can anchor to a text block but how the split screen slider functions this does load the page correctly.
We are developing locally but here is the theme example. I am attempting to link to slide 3. http://tahoe.edge-themes.com/split-screen-slider/
Backend functionality is not my strong suit. Thank you.
javascript jquery selenium navigation keypress
javascript jquery selenium navigation keypress
edited Nov 24 '18 at 3:25
Dean
asked Nov 24 '18 at 0:11
DeanDean
62
62
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27
add a comment |
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454108%2fnavigate-a-user-to-a-url-and-simulate-the-user-pressing-down-arrow-or-clicking-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Nov 24 '18 at 2:15
nickbreatonnickbreaton
406
406
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454108%2fnavigate-a-user-to-a-url-and-simulate-the-user-pressing-down-arrow-or-clicking-a%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Be a lot simpler to wrap some links into a slider
– charlietfl
Nov 24 '18 at 0:20
Not sure this will work in this case. We can anchor to a text block but how the slider functions the image does not load with the relevant text. Thank you.
– Dean
Nov 24 '18 at 3:27