我正在使用 capybara-webkit 来测试使用 jquery-tokeninput (https://github.com/loopj/jquery-tokeninput) 填充字段的表单。问题是使用 fill_in 对此不起作用。有没有办法自动测试这个?提前致谢。
最佳答案
我也一直在使用 token 输入,它的作用是隐藏您的实际输入字段,并将其替换为 id 与 token-input-{your_field_id}
匹配的另一个元素。假设您有一个 id 为 search
的字段,那么您实际上应该以 id 为 token-input-search
为目标元素。
因此示例代码片段如下:
fill_in "token-input-search", with: "hello"
之后您可以测试您的行为。
关于javascript - 在 Rails 中使用 capybara-webkit 模拟按键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9520230/