我从黄瓜开始,我正试图在我的轨道上制作一部新电影的测试。所以在我的teste1.feature中
platform :ios, '9.3'
use_frameworks!
inhibit_all_warnings!
project '/Users/user/myproject/myproject.xcodeproj'
target 'myproject' do
pod 'GooglePlaces'
pod 'GooglePlacePicker'
pod 'GoogleMaps'
pod 'Google/Analytics'
pod 'TTRangeSlider'
pod 'TNImageSliderViewController'
end
在我的teste1.step中我有
Feature: É possivel acessar a pagina de Novo Filme
Scenario: É possivel visitar paginas
Given I visit "/articles"
And I press the "Novo Filme" button
Then I should see the "/articles/new" page
Scenario: Add a movie
Given I visit "/articles"
And I press the "Novo Filme" button
Then I should see the "/articles/new" page
Given I am on a new movies page
When I fill in "article_title" with "Sta Uors"
And I fill in "f.number_field" with "10.5"
And I press "Salvar Novo Filme"
Then I should see "/articles"
Then I should see the "Sta Uors" at "tabelafilme"
但我仍然收到此错误
#Given(/^I visit "([^"]*)"$/) do
# visit article_path # Write code here that turns the phrase above into concrete actions
#end
Given (/^I visit "(.*)"/) do |place|
visit place
end
And(/^I press the "([^"]*)" button$/) do |arg|
click_on( arg ) # Write code here that turns the phrase above into concrete actions
end
Then(/^I should see the "([^"]*)" page$/) do |place|
visit "/articles/new"
end
Given (/^I am on a new movies page/) do
visit "/articles/new"
end
When (/^I fill in "(.*)" with "(.*)"/) do |field , content|
fill_in (field), :with => (content), visible: false
end
And(/^I press "([^\"]*)"/) do |button|
click_button(button)
end
Then (/^I should see "([^\"]*)"/) do |arg|
page.find_by_id('notice').text == arg
end
Then (/^I should see the "([^\"]*)" at "([^\"]*)"/) do |film, table|
expect(page).to have_css("#tebelafilme", :text => table)
find('td', text: film)
end
所以,我去项目运行并点击我的article_title来检查html页面上要放黄瓜的名字,id名称是" article_text",标签是" article_Titulo",和黄瓜找不到该字段。 有人能帮助我吗?
答案 0 :(得分:1)
首先,对于fill_in来说,the documentation看起来像是期望一个特定于这两个参数的字符串。您可以尝试fill_in "#{field}", :with => "#{content}", visible: false
来毫无疑问地为您提供字符串。
但是,如果您使用text_field
辅助方法创建字段,this answer应该这样做。看起来在名称中使用下划线创建的元素在到达DOM时会将下划线剥离。