Capybara:如何在没有'id'的情况下填充textarea?

时间:2015-05-14 12:09:45

标签: ruby selenium selenium-webdriver webdriver capybara

我需要fill_in一个没有id的文本区域。检查后:

<textarea class="stock-description-input js-short-description-textarea" placeholder="Select a product or enter a description" maxlength="64"></textarea>

你知道怎么做吗?

1 个答案:

答案 0 :(得分:5)

有不同的定位技术和方法来获得所需的元素。 stock-description-input课程看起来是一件好事。 Use send_keys()填补该区域:

text_area = first(:css, 'textarea.stock-description-input').native
text_area.send_keys('Test')