问题
Since StoreEval and getEval does not work so I added javascript as in image one Previously I used to do as
storeEval new Array("car","bus"); vehicles
getEval myitems=0;
to use the loop
Output is as
Running 'new array'
13:43:33
1.store on new Array("car","bus"); with value vehicles OK
13:43:34
2.executeScript on return 1 with value myitems OK
13:43:34
3.while on ${myitems}<3 OK
13:43:34
4.store on myitems with value myvar OK
13:43:34
echo: javascript{storedVars['vehicles'][storedVars['myvar']]}
13:43:34
6.executeScript on return ${myitems}+1 with value myitems OK
13:43:34
echo: javascript{storedVars['vehicles'][storedVars['myvar']]}
13:43:35
7.end OK
instead of printing the values of array elements its printing javascript also when i tried with
myitems < storedVars['vehicles'].length
to get the length it does not work.
Can someone help me with this
回答1:
The store
command simply assigns the value in Target to the variable in Value. In your code, you've created a variable named vehicles that contains the string "new Array("car", "bus");".
You can create your array like this:
Command = execute script
| Target = return["car", "bus"]
| Value = vehicles
Then print your array elements using a for each loop. The end result would look like this:
For each loop
You can read more about creating, reading, and adding to Selenium IDE arrays here.
来源:https://stackoverflow.com/questions/62017355/printing-array-elements-in-selenium-ide