我想使用 watir-webdriver 设置 text_field 的值。我要设置的值有左括号和右括号,例如“波士顿(02116)”。我只能设置右括号的值,而不能设置左括号。尝试了各种不同的东西,但没有任何效果。对于解决此问题的任何建议,我将不胜感激。
HTML 代码
<div id="search-container">
<div class="label">Search</div>
<div>
<form accept-charset="UTF-8" action="/search/js/update" method="get">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓">
</div>
<span role="status" aria-live="polite" class="ui-helper-hidden-accessible">1 result is available, use up and down arrow keys to navigate.
</span>
<input class="tab_header_filter search ui-autocomplete-input" id="search-list" name="project_name" type="text" value="" autocomplete="off">
</form>
</div>
<div class="clear"></div>
</div>
watir-webdriver 代码
irb
require 'watir-webdriver'
b=Watir::Browser.new
b.text_field(:id => 'search-list').set "Boston (02116)"
b.text_field(:id => 'search-list').to_subtype.set "Boston (02116)"
b.input(:class => 'tab_header_filter search ui-autocomplete-input').to_subtype.value = "Boston (02116)"
b.div(:id =>'search-container').div(:index => 1).input(:index=>1).to_subtype.set "Boston (02116)"
我已经尝试了上述命令的几种变体,它们都在文本字段中插入了 Boston 02116)。我不能让波士顿(02116)在那里。有什么想法吗?