click / clickAndWait not working

断了今生、忘了曾经 提交于 2019-12-05 22:45:13

问题


A recorded test script includes a google search.

After clicking on "Google Search", the next action was to click on a link in the test results, however during playback this happens before the browser has loaded the results, so the solution seemed to be to add a delay after the search. I tried it two ways :

  • changing "click" to "clickAndWait" with a value of 1000. This works, badly. The value of 1000 does not change the default value of 30000ms, and the playback takes 30s to complete the step.

  • calling "setTimeout" before the click with a value of 1000. This has no effect on the timeout behavior of clickAndWait.

Here is the script :

<tr>
        <td>open</td>
        <td>/</td>
        <td></td>
</tr>
<tr>
        <td>type</td>
        <td>q</td>
        <td>test search</td>
</tr>
<tr>
        <td>setTimeout</td>
        <td></td>
        <td>1000</td>
</tr>
<tr>
        <td>clickAndWait</td>
        <td>btnG</td>
        <td>1000</td>
</tr>
<tr>
        <td>click</td>
        <td>link=CLEP Test Center Search</td>
        <td></td>
</tr>
<tr>
        <td>clickAndWait</td>
        <td>link=Home</td>
        <td></td>
</tr>

If anyone can advise, thanks very much.


回答1:


I would recommend another solution by adding a waitForElementPresent command before clicking the link.

  • open /
  • type q test search
  • click btnG
  • waitForElementPresent link=CLEP Test Center Search
  • click link=CLEP Test Center Search
  • waitForElementPresent link=Home
  • click link=Home

You can find a good explanation in http://www.infoq.com/articles/testing-ajax-selenium



来源:https://stackoverflow.com/questions/3703458/click-clickandwait-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!