没有正确比较数组中的浮点数

时间:2015-09-09 14:20:21

标签: javascript jquery selenium selenium-ide

我正在尝试比较数组中的值(从网站动态添加),使用Selenium-IDE进行此比较。

出于某种原因,他们仍在使用字符串逻辑进行比较 - 所以58> 105(因为5> 1)

以下是我知道错误的代码摘录

<tr>
    <td>storeEval</td>
    <td>0</td>
    <td>i</td>
</tr>
<tr>
    <td>while</td>
    <td>storedVars['i'] &lt; storedVars['parcTotal']</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>jQuery('article.parcarticle').eq(${i}).attr('id')</td>
    <td>articleID</td>
</tr>
<tr>
    <td>storeText</td>
    <td>css=#${articleID} .table-container tr:nth-child(2) .tbl-price .price</td>
    <td>firstParcCost</td>
</tr>
<!--Remove all Commas and Currency Symbol-->
<tr>
    <td>echo</td>
    <td>${firstParcCost}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>javascript{storedVars['firstParcCost'].replace(&quot;,&quot;,&quot;&quot;).substring(1)}</td>
    <td>firstParcCost</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>javascript{parseInt(storedVars['firstParcCost'])}</td>
    <td>firstParcCost</td>
</tr>
<tr>
    <td>echo</td>
    <td>${firstParcCost}</td>
    <td></td>
</tr>
<tr>
    <td>push</td>
    <td>javascript{storedVars['firstParcCost']}</td>
    <td>firstParcCostArray</td>
</tr>
<tr>
    <td>echo</td>
    <td>${firstParcCostArray}</td>
    <td></td>
</tr>
<tr>
    <td>gotoIf</td>
    <td>storedVars['i']==0</td>
    <td>zeroSkip</td>
</tr>
<tr>
    <td>echo</td>
    <td>javascript{storedVars['firstParcCostArray'][(storedVars['i'])-1] + &quot; is bigger than &quot; + storedVars['firstParcCostArray'][(storedVars['i'])]}</td>
    <td></td>
</tr>
<tr>
    <td>assertEval</td>
    <td>storedVars['firstParcCostArray'][(storedVars['i'])-1] &gt;= storedVars['firstParcCostArray'][(storedVars['i'])]</td>
    <td>true</td>
</tr>
<tr>
    <td>label</td>
    <td>zeroSkip</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>${i}+1</td>
    <td>i</td>
</tr>
<tr>
    <td>endWhile</td>
    <td></td>
    <td></td>
</tr>

0 个答案:

没有答案