selenim web driver python repet code ultimate
how repeat code again again again this every work
I want the code below to always work and it should be repeated, and again this function should be repeated and not removed from the program.
def ref(self):
driver = self.driver
nextB2 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB2.click()
time.sleep(5)
nextB3 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB3.click()
time.sleep(6)
nextB4 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB4.click()
time.sleep(7)
driver.refresh()
time.sleep(5)
driver.switch_to_frame('ref')
driver.refresh('ref')
python selenium-webdriver webdriver
add a comment |
how repeat code again again again this every work
I want the code below to always work and it should be repeated, and again this function should be repeated and not removed from the program.
def ref(self):
driver = self.driver
nextB2 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB2.click()
time.sleep(5)
nextB3 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB3.click()
time.sleep(6)
nextB4 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB4.click()
time.sleep(7)
driver.refresh()
time.sleep(5)
driver.switch_to_frame('ref')
driver.refresh('ref')
python selenium-webdriver webdriver
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13
add a comment |
how repeat code again again again this every work
I want the code below to always work and it should be repeated, and again this function should be repeated and not removed from the program.
def ref(self):
driver = self.driver
nextB2 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB2.click()
time.sleep(5)
nextB3 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB3.click()
time.sleep(6)
nextB4 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB4.click()
time.sleep(7)
driver.refresh()
time.sleep(5)
driver.switch_to_frame('ref')
driver.refresh('ref')
python selenium-webdriver webdriver
how repeat code again again again this every work
I want the code below to always work and it should be repeated, and again this function should be repeated and not removed from the program.
def ref(self):
driver = self.driver
nextB2 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB2.click()
time.sleep(5)
nextB3 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB3.click()
time.sleep(6)
nextB4 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
nextB4.click()
time.sleep(7)
driver.refresh()
time.sleep(5)
driver.switch_to_frame('ref')
driver.refresh('ref')
python selenium-webdriver webdriver
python selenium-webdriver webdriver
asked Nov 25 '18 at 9:38
Jafar EsyJafar Esy
35
35
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13
add a comment |
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13
add a comment |
1 Answer
1
active
oldest
votes
you can use for loop with range to stop at perticular count like
for i in range(10): #10 times
ref() #function call
if you want it to run for ever
while True: #loop that never stops
ref()
you can use break and continue for conditional breaks
while True:
if foo == foo:
break #break or stop the while oop
elif foo == bar:
continue #skip current iteration and continue execution
else:
ref()
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
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%2f53466245%2fselenim-web-driver-python-repet-code-ultimate%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
you can use for loop with range to stop at perticular count like
for i in range(10): #10 times
ref() #function call
if you want it to run for ever
while True: #loop that never stops
ref()
you can use break and continue for conditional breaks
while True:
if foo == foo:
break #break or stop the while oop
elif foo == bar:
continue #skip current iteration and continue execution
else:
ref()
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
add a comment |
you can use for loop with range to stop at perticular count like
for i in range(10): #10 times
ref() #function call
if you want it to run for ever
while True: #loop that never stops
ref()
you can use break and continue for conditional breaks
while True:
if foo == foo:
break #break or stop the while oop
elif foo == bar:
continue #skip current iteration and continue execution
else:
ref()
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
add a comment |
you can use for loop with range to stop at perticular count like
for i in range(10): #10 times
ref() #function call
if you want it to run for ever
while True: #loop that never stops
ref()
you can use break and continue for conditional breaks
while True:
if foo == foo:
break #break or stop the while oop
elif foo == bar:
continue #skip current iteration and continue execution
else:
ref()
you can use for loop with range to stop at perticular count like
for i in range(10): #10 times
ref() #function call
if you want it to run for ever
while True: #loop that never stops
ref()
you can use break and continue for conditional breaks
while True:
if foo == foo:
break #break or stop the while oop
elif foo == bar:
continue #skip current iteration and continue execution
else:
ref()
answered Nov 27 '18 at 9:33
Pavan Kumar T SPavan Kumar T S
538416
538416
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
add a comment |
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
wrong to code error code how ad while True: ref()
– Jafar Esy
Nov 27 '18 at 17:38
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
how to add while True: if foo == foo: break #break or stop the while oop elif foo == bar: continue #skip current iteration and continue execution else: ref()
– Jafar Esy
Nov 28 '18 at 18:54
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
who is foo and bar
– Jafar Esy
Nov 28 '18 at 18:55
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%2f53466245%2fselenim-web-driver-python-repet-code-ultimate%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
which part of code you want to execute repeatedly or is it entire function which has to repeated
– Pavan Kumar T S
Nov 25 '18 at 11:12
all part code repeated
– Jafar Esy
Nov 25 '18 at 19:27
Just add a while loop or for loop and call the function how much time ever you want
– Pavan Kumar T S
Nov 26 '18 at 16:47
I do not know you can loop call
– Jafar Esy
Nov 27 '18 at 8:13