【问题标题】:How to append to a field in Capybara (Webdriver) rather than clear and populate如何附加到 Capybara(Webdriver)中的字段而不是清除和填充
【发布时间】:2018-07-27 14:55:41
【问题描述】:

我是水豚的新手。我正在使用 WebDriver 驱动程序,我想附加到字段值而不是覆盖整个内容。

当我使用方法 fill_in 时,它会覆盖整个值(清除然后填充)。但是我只想追加到字段中的现有值。

【问题讨论】:

    标签: capybara


    【解决方案1】:

    看起来send_keys 会成为你的朋友。

    试试find_field('Your field').native.send_keys('some text')

    【讨论】:

    • 谢谢老兄,你是这个宇宙中最棒的人!
    【解决方案2】:

    也许你想在Capybara

    中专门这样做 定义任何方法 定位器策略 = :css if(obj_locator[0]=='/' || obj_locator[0,2] == '(/')) locator_strategy = :xpath 结尾 find(locator_strategy, locator_path).native.send_keys('some text') 结尾

    【讨论】:

      猜你喜欢
      • 2012-03-19
      • 2015-05-10
      • 1970-01-01
      • 2021-10-04
      • 2016-12-09
      • 2017-07-21
      • 2012-08-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多