我遇到了一个简单的脚本问题:
Given(/^I am on the main home page$/) do
visit 'xxx.se'
end
When(/^I search for "(.*?)"$/) do
|search_term|
fill_in 'q', :with => search_term
click_on 'search'
end
Then(/^videos of large rodents are returned$/) do
expect(page).to have_content 'Samsung'
但我收到了错误
Capybara::ElementNotFound: Unable to find link or button "search"
./features/step_definitions/steps.rb:7:in `/^I search for "(.*?)"$/'
链接到这里检查元素: http://imgur.com/GLbbg7e
答案 0 :(得分:0)
尝试find("button[aria-label='Search']")
它可能会有所帮助
你可以在这里阅读点击
http://www.rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Actions
答案 1 :(得分:0)
由于click on
不支持css选择器,您可以使用find
代替
find(:css, "button.search-form-button").click