下面的作品就好了:檢查元素不存在使用WebRat
Then /^I should see a button called "([^\"]*)"$/ do |name|
response.should have_selector("li") do |li|
li.should have_selector("a") do |a|
a.should contain(name)
end
end
end
現在,我需要這樣的步驟來補充它:
Then /^I should not see a button called "([^\"]*)"$/ do |name|
[snip...]
end
標準「而且我不應該看「並不令人滿意,因爲它會在頁面的任何位置拾取目標短語 - 而不僅僅是在按鈕內。我特別需要檢查沒有包含目標文本的按鈕。
我的第一反應是去嘗試這樣的:
Then /^I should see a button called "([^\"]*)"$/ do |name|
response.should have_selector("li") do |li|
li.should have_selector("a") do |a|
a.should_not contain(name)
end
end
end
當然,只要有網頁上的任何按鍵,不包括目標文本將通過,即使有也是一個,但或多個包含目標文本的按鈕。
您的想法?
非常感謝,
史蒂文。
很高興你解決了它! – Rodreegez 2009-10-30 12:32:40