Navigate a user to a URL and simulate the user pressing down arrow or clicking a button 3 times












1















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.










share|improve this question

























  • 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
















1















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.










share|improve this question

























  • 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














1












1








1








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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



















  • 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












1 Answer
1






active

oldest

votes


















0














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






share|improve this answer























    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    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






    share|improve this answer




























      0














      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






      share|improve this answer


























        0












        0








        0







        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






        share|improve this answer













        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







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 2:15









        nickbreatonnickbreaton

        406




        406
































            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Feedback on college project

            Futebolista

            Albești (Vaslui)