2015-06-27 28 views
1

我有一个文本提交按钮,我想检查两者。水豚 - 如何检查提交按钮上的文本?

即实际的页面有:

<input class="button" type="submit" value="Continue" tabindex="3" 
name="nav[save]"></input>` 

所以我已经试过

it "I can see the Continue button" do 
    expect(page.find('input[type="submit"]').find('input[value="Continue"]')).to be 
    end 

,但我得到

Unable to find css "input[value=\"Continue\"]" 

expect(page.find('input[type="submit"]')). 
    to have_selector('input[value="Continue"]') 

但我得到

expected to find css "input[value=\"Continue\"]" but there were no matches 

回答

1

如果要同时检查你能做到在一个CSS选择器一样

input[type=\"submit\"][value=\"Continue\"] 
0

这里有一个解决方案,你的看法工作:

expect(find('.button').value).to eq 'Continue' 

在控制台上:

[1] pry(#<Cucumber::Rails::World>)> expect(find('.button').value).to eq 'Continue' 
=> true