我正在努力从selenium ide的网址获取id请你能帮助我谢谢。当我回显商店位置时,它会删除等于?请看下面输出的注释。感谢您给予的任何帮助。
当我运行ide测试时,我通过webdriver和Internet Explorer运行它,但我不认为这应该会有很大的不同。
<tr>
// gets http//website.co.uk/index.php?main_detail_id=123456789123456
<td>storeLocation</td>
<td>loc</td>
<td></td>
</tr>
<tr>
//prints http//website.co.uk/index.php?main_detail_id123456789123456
<td>echo</td>
<td>${loc}</td>
<td></td>
</tr>
<tr>
//no errors have also tried split '?'
<td>storeEval</td>
<td>"${loc}".split('=')[2]</td>
<td>mainid</td>
</tr>
<tr>
//prints nothing.
<td>echo</td>
<td>${mainid}</td>
<td></td>
</tr>
答案 0 :(得分:1)
以下是帮助您可以从网址
获取ID的代码<tr>
<td>store</td>
<td>http//website.co.uk/index.php?main_detail_id=123456789123456</td>
<td>test</td>
</tr>
<tr>
<td>store</td>
<td>1</td>
<td>delimiter</td>
</tr>
<tr>
<td>store</td>
<td>javascript{storedVars['test'].split('=')[storedVars['delimiter']]}</td>
<td>vv</td>
</tr>
<tr>
<td>echo</td>
<td>${vv}</td>
<td></td>
</tr>