我在selenium离子中停留了一点
场景是这样的
Login----- go to dashboard page--------- mouse over any menu on the top navigational bar---- on mouseover sub menu will appear as drop down-- now click any link from the drop down -- after clicking link will open in new tab
现在,从那时起,我们必须将重点转移到该新标签上,因为其余的测试将在该新标签上进行。
我写的代码如下
<tr> <td>open</td> <td>/magma/dev/</td> <td></td> </tr> <tr> <td>type</td> <td>name=user_id</td> <td>abcd</td> </tr> <tr> <td>type</td> <td>name=pass</td> <td>1234</td> </tr> <tr> <td>clickAndWait</td> <td>id=btnLogin</td> <td></td> </tr> <tr> <td>verifyTextPresent</td> <td>Costing List</td> <td></td> </tr> <tr> <td>verifyTextPresent</td> <td>Fuel</td> <td></td> </tr> <tr> <td>mouseOver</td> <td>//div[@id='smoothmenu1']/ul/li[3]</td> <td></td> </tr> <tr> <td>click</td> <td>link=Fuel Cost</td> <td></td> </tr> <tr> <td>selectWindow</td> <td>http://10.0.1.101/magma/dev/fuelcost/</td> <td></td> </tr> <tr> <td>verifyTextPresent</td> <td>Manage Fuel Cost</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Logout</td> <td></td> </tr>
此代码无法正常工作,直到从下拉菜单中单击子菜单为止,并且日志中显示错误
因此,当我尝试运行该测试用例时,它会显示错误
[警告]链接具有目标’_blank’,Selenium不支持该目标! 随机目标为:selenium_blank84419
谁能帮我正确编写代码
以下代码对我有用:
<tr> <td>storeEval</td> <td>selenium.getAllWindowNames()[1]</td> <td>windowName</td> </tr> <tr> <td>getEval</td> <td>this.doEcho("array length: "+selenium.getAllWindowNames().length);this.doEcho("Available window names: "+selenium.getAllWindowNames());this.doEcho("Selecting window: "+storedVars['windowName']);</td> <td></td> </tr> <tr> <td>selectWindow</td> <td>${windowName}</td> <td></td> </tr>
我希望它能帮助其他面临类似问题的人