Arrays selenium ide通过数组变量循环
在SeleniumIDE中,我构建了一个测试用例,其中一个数组变量存储值。我使用while循环来打印这些数组变量 这里我使用了“getEval | myarray[0]”来打印第一个值,即“postgresql”。但该值未列出。没有错误发生Arrays selenium ide通过数组变量循环,arrays,testing,selenium,selenium-ide,Arrays,Testing,Selenium,Selenium Ide,在SeleniumIDE中,我构建了一个测试用例,其中一个数组变量存储值。我使用while循环来打印这些数组变量 这里我使用了“getEval | myarray[0]”来打印第一个值,即“postgresql”。但该值未列出。没有错误发生 [info] Executing: |getEval | myarray = new Array('postgresql','mysql'); | | [info] script is: myarray = new Array('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; | |
[info]正在执行:| getEval | myarray=newarray('postgresql','mysql');||
[info]脚本是:myarray=newarray('postgresql','mysql');
[info]正在执行:| getEval | index=0;||
[info]脚本为:index=0;
[info]正在执行:| while | index
现在,在同一个测试用例中,我将“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
[info]正在执行:| getEval | myarray=newarray('postgresql','mysql');||
[info]脚本是:myarray=newarray('postgresql','mysql');
[info]正在执行:| getEval | index=0;||
[info]脚本为:index=0;
[info]正在执行:| while | index
我只需要echo打印“postgresql”和“mysql”就行了。
我对selenium很陌生,请帮我解决这个问题。这帮我解决了问题,希望它也能帮助其他人
[info] Executing: |storeEval | new Array("postgresql","mysql"); | myarray
[info] script is: new Array("postgresql","mysql");
[info] Executing: |getEval | index=0;
[info] script is: index=0;
[info] Executing: |while | index < storedVars['myarray'].length;
[info] Executing: |storeEval | index | temp
[info] script is: index
[info] Executing: |echo | javascript{storedVars['myarray'][storedVars['temp']]}
[info] echo: postgresql
[info] Executing: |getEval | index++;
[info] script is: index++;
[info] Executing: |endWhile | | |
[info] Executing: |while | index < storedVars['myarray'].length; |
[info] Executing: |storeEval | index | temp |
[info] script is: index
[info] Executing: |echo | javascript{storedVars['myarray'][storedVars['temp']]}
[info] echo: mysql
[info] Executing: |getEval | index++; | |
[info] script is: index++;
[info] Executing: |endWhile | | |
[info] Executing: |while | index < storedVars['myarray'].length;
[info]正在执行:| storeEval |新数组(“postgresql”、“mysql”)| myarray
[info]脚本是:新数组(“postgresql”、“mysql”);
[info]正在执行:| getEval | index=0;
[info]脚本为:index=0;
[info]执行:| while | index
以下是用于剪切和粘贴的源HTML中的上述内容:
<tr>
<td>storeEval</td>
<td>new Array("postgresql","mysql");</td>
<td>myarray</td>
</tr>
<tr>
<td>getEval</td>
<td>index=0;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < storedVars['myarray'].length</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>temp</td>
</tr>
<tr>
<td>echo</td>
<td>javascript{storedVars['myarray'][storedVars['temp']]}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
仓库
新数组(“postgresql”、“mysql”);
myarray
格特瓦尔
指数=0;
虽然
索引存储区VARS['myarray'].长度
仓库
指数
临时雇员
回声
javascript{storedVars['myarray'][storedVars['temp']]}
格特瓦尔
索引++;
结束时