I'm writing a script using a testing framework to recreate a user's action on these labels. I'm using the following:
listBox.LabelButton.Keys("[Enter]")
winword.WaitProcess("winword", 2000)
listBox.LabelButton2.Keys("[Enter]")
winword.WaitProcess("winword", 2000)
listBox.LabelButton3.Keys("[Enter]")
winword.WaitProcess("winword", 2000)
all the way down to listBox.LabelButton5
. How can I iterate through this in order to minimize this redundancy on Python?
I tried
listbox.LabelButton.Keys("[Enter]")
winword.WaitProcess("winword",2000)
for i in range (2,6):
listBox.LabelButton + str(i).Keys("[Enter]")
winword.WaitProcess("winword", 2000)
This is not syntactically correct in Python. What is the appropriate approach?