dongyou7739 2014-08-28 04:15
浏览 128
已采纳

Selenium PHP单元如何等待网格中的过滤操作

I have a grid with an filtering option. Whenever I sendKeys to the filtering field, it will start searching

I'm using Selenium: facebook webdriver with phpunit.

$this->webDriver->findElement(WebDriverBy::xpath('//*[@id="datatable_classrooms_wrapper"]/div[3]/div[2]/div[3]/div/table/tfoot/tr/td[1]/div/input'))->click();  
$var = "Selenium";
for ($i = 0; $i<strlen($var); $i++) {$character = \substr($var, $i,1);
$this->webDriver->getKeyboard()->sendKeys($character);
}
// Here it searches for the item $character in the grid
// More actions as followed, but how do I wait here until the searches are done?

Here I will search for Selenium in the grid but how do I wait until it's done filtering? Sometimes it can take up to 12 seconds before it filters.

I guess I could just put a sleep(15); in it but if it happens to be longer then 15 seconds it won't work. Also implicit wait and explicit wait won't do the trick here , since sending the keys goes as normal as it can get.

Any suggestions towards how I can do this?

HTML:

<td class="dataTables_filter text-left" rowspan="1" colspan="1" style="width: 277px;"> 
<div class="input-group">
<input type="text" value="" data-position="1" data-type="text" class="form-control input-sm"></div></td>
  • 写回答

1条回答 默认 最新

  • douaonong7807 2014-08-28 04:38
    关注

    Well, if you need somehow wait untill search will be finished, here is my sugesstions:

    1. Do you have loading animarion while search appears? If yes, it will help you. You can set explicit wait until this loadin animation will dissappear, then the search will completed

    2. Possible results appears somewhere (e.g. in table, i don't know). So you can wait until first element in table will appear

    3. Maybe during search some attribute changes (e.g. in input), or it's become disabled, or btn becomes disabled

    4. Maybe during search you can get requests which server send, and verify it's content,

    I don't know what else... i need to see it. Anyway, try to find some place that changes during search (or after search), it will help you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部