0

How can i change the 0 to be a variable that i can increase the value of when i loop the code

javaScript = "document.getElementsByTagName('cite')[0].click();"
browser.execute_script(javaScript)
asked Jul 31, 2021 at 14:29

1 Answer 1

1

in python you could do this :

i = 0
javaScript = f"document.getElementsByTagName('cite')[{i}].click();"
browser.execute_script(javaScript)

I'm not sure how you want to iterate, but a standard way would be something like this :

i = 0
for x in range(5):
 javaScript = f"document.getElementsByTagName('cite')[{i}].click();"
 driver.execute_script(javaScript)
 i = i + 1
answered Jul 31, 2021 at 16:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.