2015-06-27 29 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