在 selenium ide 中,我构建了一个测试用例,其中一个数组变量存储值。我使用 while 循环来打印这些数组变量。
在这里,我使用“getEval | myarray[0]”来打印第一个值,即“postgresql”。但未列出该值。没有错误发生。
[info] Executing: |getEval | myarray = new Array('postgresql','mysql'); | |
[info] script is: myarray = new Array('postgresql','mysql');
[info] Executing: |getEval | index=0; | |
[info] script is: index=0;
[info] Executing: |while | index < myarray.length; | |
[info] Executing: |getEval | myarray[0] | mynewvalue |
[info] script is: myarray[0]
[info] Executing: |echo | ${mynewvalue} | |
[info] echo: ${mynewvalue}
[info] Executing: |getEval | index++; | |
[info] script is: index++;
[info] Executing: |endWhile | | |
[info] Executing: |while | index < myarray.length; | |
[info] Executing: |getEval | myarray[0] | mynewvalue |
[info] script is: myarray[0]
[info] Executing: |echo | ${mynewvalue} | |
[info] echo: ${mynewvalue}
[info] Executing: |getEval | index++; | |
[info] script is: index++;
[info] Executing: |endWhile | | |
[info] Executing: |while | index < myarray.length; | |
现在再次在同一个测试用例中,我将“getEval | myarray[0]”更改为“getEval | myarray[${index}]”以按循环索引列出数组值。
现在我收到以下错误:
[info] Executing: |getEval | myarray = new Array('postgresql','mysql'); | |
[info] script is: myarray = new Array('postgresql','mysql');
[info] Executing: |getEval | index=0; | |
[info] script is: index=0;
[info] Executing: |while | index < myarray.length; | |
[info] Executing: |getEval | myarray[${index}] | mynewvalue |
[info] script is: myarray[${index}]
[error] Threw an exception: missing ] in index expression
我只需要 echo 打印“postgresql”,“mysql”是单独的新行。我对硒很陌生,请帮我解决这个问题。