dongyou7739 2014-08-28 12: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 12: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

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

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示