你必须点击这个按钮
<button type="submit" aria-label="Search..." class="s-btn s-btn__primary btn-topbar-primary js-search-submit"><svg aria-hidden="true" class="svg-icon mx0 iconSearch" width="18" height="18" viewBox="0 0 18 18"><path d="M12.86 11.32L18 16.5 16.5 18l-5.18-5.14v-.35a7 7 0 1 1 1.19-1.19h.35zM7 12A5 5 0 1 0 7 2a5 5 0 0 0 0 10z"></path></svg></button>
按钮的类型属性值为
submit
所以我们可以用它来定位那个按钮,这是代码
browser.goto 'https://www.stackoverflow.com'
browser.text_field(name: "q").set('user:963076')
browser.button(type: 'submit').click