jquery-select2 - 如何使用 codeception 测试 select2 动态标签
问题描述
从预先填充的列表中选择一个选项的工作方式如下:
$selector = "select[name='tags']";
$this->tester->openSelect2($selector);
$this->tester->selectOptionForSelect2($selector, array('text' => $tag));
$this->tester->closeSelect2($selector);
找到了这个要点https://gist.github.com/tortuetorche/412fbac4f17db5e78e79。
问题是我的 select2 也有动态标签。(https://select2.org/tagging)
有没有人想出如何使用代码接收创建动态标签?谢谢。
解决方案
通常我使用WebDriver Keys
该类来测试动态 select2 字段。
要填充动态 select2 输入,您可以尝试以下操作:
// Fill your dynamic tag with the option you want to search
$I->fillField($selector, 'Orang');
// Then, wait for the option is loaded
$I->waitForText('Orange', 30);
// Finaly, use WebDriverKeys to select the option
$I->pressKey($selector, \Facebook\WebDriver\WebDriverKeys::ENTER);
它也可以选择多个选项。
推荐阅读
- javascript - 在函数参数中声明对象属性类型
- sql - 如何更新列中具有最大值的一行(SQL Server)
- python - 我正在尝试使用 flask_socketio 制作一个简单的聊天应用程序,但它无法正常工作
- c# - .NET Core 3.1 登录与用户名/电子邮件混淆
- reactjs - PassportJS 没有反序列化 Heroku 服务器上的用户
- javascript - 递归获取请求
- c++ - 为没有模板参数的可变参数模板递归创建基本案例
- angular - 使用 agm-direction Ionic 时的航点抛出问题
- sql - Microsoft SQL Server:如何从第一个查询中过滤出第二个查询的结果
- java - 更改依赖项后,我的应用程序不断崩溃