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 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?