我正在尝试使用Capybara与RSpec匹配类属性。
我可以非常清楚地看到元素和他们的类,但无论我尝试什么,Capybara似乎对类都一无所知。但它可以找到id没问题。请问有什么线索吗? https://gist.github.com/1428472
visit "/admin/staff?mobile=1"
page.should have_selector("ul") #works
page.should have_selector("body#page") #works
page.should have_selector("html.ui-mobile") #fails
page.should have_selector("body.ui-mobile-viewport") #fails
save_and_open_page # this launches the page so I can see it and verify these attributes are indeed there.
html:
< html class="ui-mobile" >
< body class="ui-mobile-viewport" id="page" >
我也设置了一个断点并做了这些也没用的东西。
#works
p find('body')[:id]
p find(:xpath, '//body[@id="page"]')
# doesn't work
p find('body')[:class]
p find(:xpath, '//html[@class="ui-mobile"]')
发生了什么事?
更新:事实证明它确实有效,但问题是save_and_open_page显示的html与资生堂看到的不同。当我在save_and_open_page之后立即中断并放置page.html时,它会有所不同。它通常是相同的,但是一堆类属性和其他一些东西一样。很奇怪。