Ruby on Rails: Cucumber: как проверить тег стиля определенного элемента - PullRequest
1 голос
/ 24 июня 2010

У меня есть это

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)

Есть идеи?

1 Ответ

3 голосов
/ 24 июня 2010

Попробуйте использовать что-то похожее на page.should have_xpath ("// tag [@ class = 'class', @ id = 'id']")

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

это однозначно работает

...