if statement of button found












0















My goal is, if a page contains the specified button, click it, and increase the amt_clicked by 1. When amt_clicked is greater than 15, wait for 60 seconds and reset amt_clicked. I have no idea how do this if statement. Example:



var amt_clicked = 0;
while (1) {
while (amt_clicked < 15) {

if (button found) { // this is where I am lost
iimPlay("TAG POS={{amt_clicked}} TYPE=BUTTON ATTR=TXT:Get");
amt_clicked++;
}
}

iimPlay("WAIT SECONDS=60");
amt_clicked = 0;
}









share|improve this question

























  • @Rajesh markup? This is for imacros

    – Kiwa
    Nov 27 '18 at 5:13











  • That's an infinite loop. I recommend setInterval().

    – Redwolf Programs
    Nov 27 '18 at 5:17











  • What is button found returning here. Is it true or false?

    – Saugat Bhattarai
    Nov 27 '18 at 5:21











  • @SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

    – Kiwa
    Nov 27 '18 at 5:24











  • it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

    – Tim Vanderzeil
    Nov 27 '18 at 11:30


















0















My goal is, if a page contains the specified button, click it, and increase the amt_clicked by 1. When amt_clicked is greater than 15, wait for 60 seconds and reset amt_clicked. I have no idea how do this if statement. Example:



var amt_clicked = 0;
while (1) {
while (amt_clicked < 15) {

if (button found) { // this is where I am lost
iimPlay("TAG POS={{amt_clicked}} TYPE=BUTTON ATTR=TXT:Get");
amt_clicked++;
}
}

iimPlay("WAIT SECONDS=60");
amt_clicked = 0;
}









share|improve this question

























  • @Rajesh markup? This is for imacros

    – Kiwa
    Nov 27 '18 at 5:13











  • That's an infinite loop. I recommend setInterval().

    – Redwolf Programs
    Nov 27 '18 at 5:17











  • What is button found returning here. Is it true or false?

    – Saugat Bhattarai
    Nov 27 '18 at 5:21











  • @SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

    – Kiwa
    Nov 27 '18 at 5:24











  • it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

    – Tim Vanderzeil
    Nov 27 '18 at 11:30
















0












0








0








My goal is, if a page contains the specified button, click it, and increase the amt_clicked by 1. When amt_clicked is greater than 15, wait for 60 seconds and reset amt_clicked. I have no idea how do this if statement. Example:



var amt_clicked = 0;
while (1) {
while (amt_clicked < 15) {

if (button found) { // this is where I am lost
iimPlay("TAG POS={{amt_clicked}} TYPE=BUTTON ATTR=TXT:Get");
amt_clicked++;
}
}

iimPlay("WAIT SECONDS=60");
amt_clicked = 0;
}









share|improve this question
















My goal is, if a page contains the specified button, click it, and increase the amt_clicked by 1. When amt_clicked is greater than 15, wait for 60 seconds and reset amt_clicked. I have no idea how do this if statement. Example:



var amt_clicked = 0;
while (1) {
while (amt_clicked < 15) {

if (button found) { // this is where I am lost
iimPlay("TAG POS={{amt_clicked}} TYPE=BUTTON ATTR=TXT:Get");
amt_clicked++;
}
}

iimPlay("WAIT SECONDS=60");
amt_clicked = 0;
}






javascript imacros






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 27 '18 at 5:18







Kiwa

















asked Nov 27 '18 at 5:06









KiwaKiwa

176




176













  • @Rajesh markup? This is for imacros

    – Kiwa
    Nov 27 '18 at 5:13











  • That's an infinite loop. I recommend setInterval().

    – Redwolf Programs
    Nov 27 '18 at 5:17











  • What is button found returning here. Is it true or false?

    – Saugat Bhattarai
    Nov 27 '18 at 5:21











  • @SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

    – Kiwa
    Nov 27 '18 at 5:24











  • it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

    – Tim Vanderzeil
    Nov 27 '18 at 11:30





















  • @Rajesh markup? This is for imacros

    – Kiwa
    Nov 27 '18 at 5:13











  • That's an infinite loop. I recommend setInterval().

    – Redwolf Programs
    Nov 27 '18 at 5:17











  • What is button found returning here. Is it true or false?

    – Saugat Bhattarai
    Nov 27 '18 at 5:21











  • @SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

    – Kiwa
    Nov 27 '18 at 5:24











  • it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

    – Tim Vanderzeil
    Nov 27 '18 at 11:30



















@Rajesh markup? This is for imacros

– Kiwa
Nov 27 '18 at 5:13





@Rajesh markup? This is for imacros

– Kiwa
Nov 27 '18 at 5:13













That's an infinite loop. I recommend setInterval().

– Redwolf Programs
Nov 27 '18 at 5:17





That's an infinite loop. I recommend setInterval().

– Redwolf Programs
Nov 27 '18 at 5:17













What is button found returning here. Is it true or false?

– Saugat Bhattarai
Nov 27 '18 at 5:21





What is button found returning here. Is it true or false?

– Saugat Bhattarai
Nov 27 '18 at 5:21













@SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

– Kiwa
Nov 27 '18 at 5:24





@SaugatBhattarai I don't know. I am using imacro (firefox extension) for this, so I don't know if it returns anything at all.

– Kiwa
Nov 27 '18 at 5:24













it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

– Tim Vanderzeil
Nov 27 '18 at 11:30







it might be easier to code this in selenium ide: If | ${LastcommandOK} | ....do something

– Tim Vanderzeil
Nov 27 '18 at 11:30














2 Answers
2






active

oldest

votes


















0














This will run 20 times per second, using the window.setInterval() function:



var amt_clicked = 0;
var amt_cooldown = 1200;
setInterval(function(){
if (amt_cooldown === 0)
amt_cooldown = 1200;
else if (amt_cooldown < 1200)
amt_cooldown -= 1;
else if (amt_clicked > 15) {
amt_clicked = 1;
amt_cooldown -= 1;
} else {
amt_clicked -= 1;
//Click
}, 50);





share|improve this answer
























  • I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

    – Kiwa
    Nov 27 '18 at 5:21



















0














You can use combination of setInterval and setTimeout.
I have added comments to code for you to understand.






var amt_clicked = 0;
var setTimeoutInProcess = false;

//processing the interval click function
setInterval(() => {
checkButtonAgain();
}, 200);


function checkButtonAgain() {

var element = document.getElementById('iNeedtoBeClicked');

//if clicked 15 times then need to wait for 60 seconds
if (amt_clicked === 15) {
if (!setTimeoutInProcess) {
setTimeoutInProcess = true;
setTimeout(function() {
//resetting the amt-clicked
amt_clicked = 0;
setTimeoutInProcess = false;
}, 60000);
} else {
console.log('waiting');
}
} else if (typeof(element) != 'undefined' && element != null) {
//triggering click and increasing the amt_clicked
element.click();
amt_clicked++;
}
console.log(amt_clicked);
}

<button id="iNeedtoBeClicked">Click ME Button</button>








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%2f53493082%2fif-statement-of-button-found%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    This will run 20 times per second, using the window.setInterval() function:



    var amt_clicked = 0;
    var amt_cooldown = 1200;
    setInterval(function(){
    if (amt_cooldown === 0)
    amt_cooldown = 1200;
    else if (amt_cooldown < 1200)
    amt_cooldown -= 1;
    else if (amt_clicked > 15) {
    amt_clicked = 1;
    amt_cooldown -= 1;
    } else {
    amt_clicked -= 1;
    //Click
    }, 50);





    share|improve this answer
























    • I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

      – Kiwa
      Nov 27 '18 at 5:21
















    0














    This will run 20 times per second, using the window.setInterval() function:



    var amt_clicked = 0;
    var amt_cooldown = 1200;
    setInterval(function(){
    if (amt_cooldown === 0)
    amt_cooldown = 1200;
    else if (amt_cooldown < 1200)
    amt_cooldown -= 1;
    else if (amt_clicked > 15) {
    amt_clicked = 1;
    amt_cooldown -= 1;
    } else {
    amt_clicked -= 1;
    //Click
    }, 50);





    share|improve this answer
























    • I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

      – Kiwa
      Nov 27 '18 at 5:21














    0












    0








    0







    This will run 20 times per second, using the window.setInterval() function:



    var amt_clicked = 0;
    var amt_cooldown = 1200;
    setInterval(function(){
    if (amt_cooldown === 0)
    amt_cooldown = 1200;
    else if (amt_cooldown < 1200)
    amt_cooldown -= 1;
    else if (amt_clicked > 15) {
    amt_clicked = 1;
    amt_cooldown -= 1;
    } else {
    amt_clicked -= 1;
    //Click
    }, 50);





    share|improve this answer













    This will run 20 times per second, using the window.setInterval() function:



    var amt_clicked = 0;
    var amt_cooldown = 1200;
    setInterval(function(){
    if (amt_cooldown === 0)
    amt_cooldown = 1200;
    else if (amt_cooldown < 1200)
    amt_cooldown -= 1;
    else if (amt_clicked > 15) {
    amt_clicked = 1;
    amt_cooldown -= 1;
    } else {
    amt_clicked -= 1;
    //Click
    }, 50);






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 27 '18 at 5:16









    Redwolf ProgramsRedwolf Programs

    253311




    253311













    • I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

      – Kiwa
      Nov 27 '18 at 5:21



















    • I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

      – Kiwa
      Nov 27 '18 at 5:21

















    I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

    – Kiwa
    Nov 27 '18 at 5:21





    I don't think this is what I wanted. I edited my code. Its just 1 line I am lost on

    – Kiwa
    Nov 27 '18 at 5:21













    0














    You can use combination of setInterval and setTimeout.
    I have added comments to code for you to understand.






    var amt_clicked = 0;
    var setTimeoutInProcess = false;

    //processing the interval click function
    setInterval(() => {
    checkButtonAgain();
    }, 200);


    function checkButtonAgain() {

    var element = document.getElementById('iNeedtoBeClicked');

    //if clicked 15 times then need to wait for 60 seconds
    if (amt_clicked === 15) {
    if (!setTimeoutInProcess) {
    setTimeoutInProcess = true;
    setTimeout(function() {
    //resetting the amt-clicked
    amt_clicked = 0;
    setTimeoutInProcess = false;
    }, 60000);
    } else {
    console.log('waiting');
    }
    } else if (typeof(element) != 'undefined' && element != null) {
    //triggering click and increasing the amt_clicked
    element.click();
    amt_clicked++;
    }
    console.log(amt_clicked);
    }

    <button id="iNeedtoBeClicked">Click ME Button</button>








    share|improve this answer






























      0














      You can use combination of setInterval and setTimeout.
      I have added comments to code for you to understand.






      var amt_clicked = 0;
      var setTimeoutInProcess = false;

      //processing the interval click function
      setInterval(() => {
      checkButtonAgain();
      }, 200);


      function checkButtonAgain() {

      var element = document.getElementById('iNeedtoBeClicked');

      //if clicked 15 times then need to wait for 60 seconds
      if (amt_clicked === 15) {
      if (!setTimeoutInProcess) {
      setTimeoutInProcess = true;
      setTimeout(function() {
      //resetting the amt-clicked
      amt_clicked = 0;
      setTimeoutInProcess = false;
      }, 60000);
      } else {
      console.log('waiting');
      }
      } else if (typeof(element) != 'undefined' && element != null) {
      //triggering click and increasing the amt_clicked
      element.click();
      amt_clicked++;
      }
      console.log(amt_clicked);
      }

      <button id="iNeedtoBeClicked">Click ME Button</button>








      share|improve this answer




























        0












        0








        0







        You can use combination of setInterval and setTimeout.
        I have added comments to code for you to understand.






        var amt_clicked = 0;
        var setTimeoutInProcess = false;

        //processing the interval click function
        setInterval(() => {
        checkButtonAgain();
        }, 200);


        function checkButtonAgain() {

        var element = document.getElementById('iNeedtoBeClicked');

        //if clicked 15 times then need to wait for 60 seconds
        if (amt_clicked === 15) {
        if (!setTimeoutInProcess) {
        setTimeoutInProcess = true;
        setTimeout(function() {
        //resetting the amt-clicked
        amt_clicked = 0;
        setTimeoutInProcess = false;
        }, 60000);
        } else {
        console.log('waiting');
        }
        } else if (typeof(element) != 'undefined' && element != null) {
        //triggering click and increasing the amt_clicked
        element.click();
        amt_clicked++;
        }
        console.log(amt_clicked);
        }

        <button id="iNeedtoBeClicked">Click ME Button</button>








        share|improve this answer















        You can use combination of setInterval and setTimeout.
        I have added comments to code for you to understand.






        var amt_clicked = 0;
        var setTimeoutInProcess = false;

        //processing the interval click function
        setInterval(() => {
        checkButtonAgain();
        }, 200);


        function checkButtonAgain() {

        var element = document.getElementById('iNeedtoBeClicked');

        //if clicked 15 times then need to wait for 60 seconds
        if (amt_clicked === 15) {
        if (!setTimeoutInProcess) {
        setTimeoutInProcess = true;
        setTimeout(function() {
        //resetting the amt-clicked
        amt_clicked = 0;
        setTimeoutInProcess = false;
        }, 60000);
        } else {
        console.log('waiting');
        }
        } else if (typeof(element) != 'undefined' && element != null) {
        //triggering click and increasing the amt_clicked
        element.click();
        amt_clicked++;
        }
        console.log(amt_clicked);
        }

        <button id="iNeedtoBeClicked">Click ME Button</button>








        var amt_clicked = 0;
        var setTimeoutInProcess = false;

        //processing the interval click function
        setInterval(() => {
        checkButtonAgain();
        }, 200);


        function checkButtonAgain() {

        var element = document.getElementById('iNeedtoBeClicked');

        //if clicked 15 times then need to wait for 60 seconds
        if (amt_clicked === 15) {
        if (!setTimeoutInProcess) {
        setTimeoutInProcess = true;
        setTimeout(function() {
        //resetting the amt-clicked
        amt_clicked = 0;
        setTimeoutInProcess = false;
        }, 60000);
        } else {
        console.log('waiting');
        }
        } else if (typeof(element) != 'undefined' && element != null) {
        //triggering click and increasing the amt_clicked
        element.click();
        amt_clicked++;
        }
        console.log(amt_clicked);
        }

        <button id="iNeedtoBeClicked">Click ME Button</button>





        var amt_clicked = 0;
        var setTimeoutInProcess = false;

        //processing the interval click function
        setInterval(() => {
        checkButtonAgain();
        }, 200);


        function checkButtonAgain() {

        var element = document.getElementById('iNeedtoBeClicked');

        //if clicked 15 times then need to wait for 60 seconds
        if (amt_clicked === 15) {
        if (!setTimeoutInProcess) {
        setTimeoutInProcess = true;
        setTimeout(function() {
        //resetting the amt-clicked
        amt_clicked = 0;
        setTimeoutInProcess = false;
        }, 60000);
        } else {
        console.log('waiting');
        }
        } else if (typeof(element) != 'undefined' && element != null) {
        //triggering click and increasing the amt_clicked
        element.click();
        amt_clicked++;
        }
        console.log(amt_clicked);
        }

        <button id="iNeedtoBeClicked">Click ME Button</button>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 27 '18 at 5:34

























        answered Nov 27 '18 at 5:28









        Just codeJust code

        10.4k53066




        10.4k53066






























            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%2f53493082%2fif-statement-of-button-found%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

            Contact image not getting when fetch all contact list from iPhone by CNContact

            count number of partitions of a set with n elements into k subsets

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks