2010-06-24 3 views
1

나는이루비 레일에 : 오이 : 특정 요소의 스타일 태그를 확인하는 방법

Then /^the "([^\"]*)" tag with the id "([^\"]*)" should have the style "([^\"]*)"$/ do |tag,id,style| 
    if page.respond_to? :should 
     page.should have_selector(tag, :id => id, :style => style) 
    else 
     assert page.has_selector?(tag, :id => id, :style => style) 
    end 
end 

이 그리고 이건 내 오이 단계

And the "div" tag with the id "preview" should have the style "display: block;" 

입니다 그리고 이것은 내가 오류입니다 :

undefined method `has_selector?' for #<Capybara::Session:0x1065b5fc0> (NoMethodError) 

아이디어가 있으십니까?

답변

3

봅니다

Then /^I should see trivial div$/ do 
    page.has_xpath?("//div[@style='display:none' and @id='my_form']") 
end 

이 하나는 확실히

작동 page.should의 have_xpath ("// 태그 [@ 클래스 = '클래스'@ 아이디 = '아이디']")로 비슷한 사용
+0

이 오류가 발생했습니다. NativeException : java.lang.RuntimeException : HtmlPage (http : //cucumber.test)에서 XPath> // div [@ style = 'display : none;', @ id = 'preview'] < com/objects/dance-dance-dance/build) @ 1286076580 (Culerity :: CulerityException) – NullVoxPopuli