我根据一些教程创建了两个文件(我现在找不到) 首先是步骤:
Given(/^: i am on "([^"]*)"$/) do |path_to|
visit path_to # Write code here that turns the phrase above into concrete actions
end
When(/^: I type ".*?" in search field$/) do |string_search|
TXT_SEARCH= ".//*[@id='masthead-search-term']" # Write code here that turns the phrase above into concrete actions
BTN_SEARCH= ".//*[@id='search-btn']"
find(:xpath,TXT_SEARCH).set string_search
find(:xpath,BTN_SEARCH).click
end
Then(/^: i should see install cucumber$/) do |string_expectation|
page.should have_content string_expectation # Write code here that turns the phrase above into concrete actions
end
,第二个是功能
Feature: as a consumer, i want to search th in yt
Scenario: search dth on yt
Given : i am on "http://youtube.com"
When : I type install cucumber in search field
Then : i should see install cucumber
但是当我尝试运行它时不起作用..我收到了错误
您可以使用以下代码段实现未定义步骤的步骤定义:
给(/ ^:我在"([^"] *)" $ /)do | arg1 | (...)
为什么呢?一切都像在YT