我和一些同学正在构建AirBNB的Rails/Angular克隆,并且我似乎遇到了一些rspec /水豚问题!水豚/ rspec的问题在页面上找到一个角度链接
我有以下测试......
context 'users are able to add a space' do scenario 'adding a space' do visit '/' click_link 'Post a space' fill_in 'Name', with: 'my hotel' fill_in 'Location', with: 'London' fill_in 'Price', with: '100' attach_file "Image", "spec/asset_specs/photo/Elephant.jpg" fill_in 'Details', with: 'single bedroom with ensuite' fill_in 'Available from', with: Date.new(2016,03,15) fill_in 'Available to', with: Date.new(2016,03,15) click_button 'Create Space' within 'ul#spaces' do expect(page).to have_content 'Location: London' expect(page.find('.space_thumb')['src']).to have_content 'Elephant.jpg' end end end end
我的看法如下......
<input id='search' ng-model='query'></br>
<section ng-if='spaces == false'>
<p>no spaces yet...</p>
</section>
<a ng-href='/spaces/new' id='post_space'>Post a space</a>
<section>
<ul id='spaces' ng-repeat='space in spaces | filter:query'>
<li>
<h5>{{space.name}}</h5>
<img class='space_thumb' ng-src={{space.image_url}}/>
<p>Location: {{space.location}}</p>
<p>Price: {{space.price}}</p>
<p>Details: {{space.details}}</p>
<p>Available from: {{space.available_from}}</p>
<p>Available to: {{space.available_to}}</p>
</li>
</ul>
</section>
然而,当我使用默认的驱动程序来运行测试,我得到以下错误...
Capybara::ElementNotFound:
Unable to find link "Post a space"
然而,当我使用硒时,它工作正常,但是接着我的测试检查了图像src,它失败了,因为它返回了默认的missing.png文件。即时猜测,只是因为硒不允许豚足够的时间来上传图片...
是否有一个角友好的司机,我可以使用或我应该放弃这个和测试量角器或类似...
谢谢!
什么是你的'Capybara.default_max_wait_time'设置为?默认值是2秒,因此将其设置为更高的值可能是个好主意。只要你访问你的网页,如果它找不到链接,它会在2秒钟后超时并放弃。尝试增加到5或10,看看是否有帮助。 – Phil