Here’s my specific example:
JavaScript
x
19
19
1
param1 = 'XXXXXXXXXXX'
2
param2 = 'XXXX'
3
param3 = 'XXXX'
4
param4 = 'XXXX'
5
param5 = 'XXXX'
6
param6 = 'XXXX'
7
#param7 below holds the (always numerical) value that needs to be incremented so that param7 = '2' in the next pass through
8
param7 = '1'
9
10
#url of fantasy league with statistics
11
url = ('https://www.fantrax.com/fantasy/league/'+param1+'/players'
12
+';positionOrGroup='+param2
13
+';miscDisplayType='+param3
14
+';seasonOrProjection=SEASON_9'+param4
15
#so on and so forth
16
+';parameterThatNeedsIncremented'+param7)
17
18
browser.get(url)
19
I need the numerical value of param7 in this example to increase by a count of 1 before each pass up to param7 = ’30’.
Is there any way to create a list or dict containing values ‘1’ through ’30’ and tell param7 to use use move through the dict at index + 1?
Advertisement
Answer
You can use a for loop with a range() function which returns a sequence of numbers, starting from first number specified, incrementing by 1 (by default), and stoping before second specified number.
JavaScript
1
19
19
1
param1 = 'XXXXXXXXXXX'
2
param2 = 'XXXX'
3
param3 = 'XXXX'
4
param4 = 'XXXX'
5
param5 = 'XXXX'
6
param6 = 'XXXX'
7
8
for param7 in range(1, 31):
9
param7 = str(param7) # If it needs to be string
10
#url of fantasy league with statistics
11
url = ('https://www.fantrax.com/fantasy/league/'+param1+'/players'
12
+';positionOrGroup='+param2
13
+';miscDisplayType='+param3
14
+';seasonOrProjection=SEASON_9'+param4
15
#so on and so forth
16
+';parameterThatNeedsIncremented'+param7)
17
18
browser.get(url)
19