if statement of button found
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
add a comment |
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
@Rajesh markup? This is for imacros
– Kiwa
Nov 27 '18 at 5:13
That's an infinite loop. I recommendsetInterval()
.
– 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
add a comment |
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
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
javascript imacros
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 recommendsetInterval()
.
– 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
add a comment |
@Rajesh markup? This is for imacros
– Kiwa
Nov 27 '18 at 5:13
That's an infinite loop. I recommendsetInterval()
.
– 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
add a comment |
2 Answers
2
active
oldest
votes
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);
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
add a comment |
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>
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%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
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);
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
add a comment |
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);
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
add a comment |
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);
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);
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
add a comment |
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
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
edited Nov 27 '18 at 5:34
answered Nov 27 '18 at 5:28
Just codeJust code
10.4k53066
10.4k53066
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%2f53493082%2fif-statement-of-button-found%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
@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