[英]Cucumber::Core::Gherkin::ParseError: how to solve it?
I am a newbie in ruby and want to build an autotesting system for a webapplication.我是 ruby 的新手,想为 web 应用程序构建一个自动测试系统。 I started to study the bunch od capybara + cucumber on ruby.我开始研究 ruby 上的水豚 + cucumber。
I found an example and tried to reproduce it.我找到了一个例子并试图重现它。 There is the project sturcture:有项目结构:
devTests
features
step_definitions
test_steps.rb
support
env.rb
tests
test_send_mail.feature
Gemfile
Gemfile.lock
Feature file has the text:功能文件有以下文字:
Feature: Log in to site
Scenario: Log in to site on English
Given Go to page "http://localhost:3000/login"
And Select text "English" in dropdownlist id "lang"
And Wait 5 second
And Input text "admin" in field with id "session_email"
And Input text "123" in field with id "session_password"
And Press button with text "Log in"
And Wait 5 second
and step_definitions和 step_definitions
Given(/^Go to page "(.*?)"$/) do |page|
visit page
end
Given(/^Select text "(.*?)" in dropdownlist id "(.*?)"$/) do |text, select_id|
find("//select[@id='#{select_id}']/option[text()='#{text}']").click
end
Given(/^Wait (\d+) second(?:|s)$/) do |sec|
sleep sec.to_i
end
Given(/^Input text "(.*?)" in field with id "(.*?)"$/) do |text, field_id|
find("//input[@id='#{field_id}']").set(text)
end
Given(/^Input text "(.*?)" in field with id "(.*?)"$/) do |text, field_id|
find("//input[@id='#{field_id}']").set(text)
end
Given(/^Press button with text "(.*?)"$/) do |text|
find("//input[@value='#{text}']").click
end
Given(/^Wait (\d+) second(?:|s)$/) do |sec|
sleep sec.to_i
end
When I run the test, then I got parser errors当我运行测试时,我得到了解析器错误
PS D:\07 TestConwize\devTests> cucumber
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows
features/tests/test_send_mail.feature: Parser errors:
(1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Feature: Log in to site'
(2:3): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Scenario: Log in to site on English'
(3:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'Given Go to page "http://localhost:3000/login"'
(4:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Select text "English" in dropdownlist id "lang"'
(5:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Wait 5 second'
(6:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Input text "admin" in field with id
"session_email"'
(7:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Input text "123" in field with id "session_password"'
(8:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Press button with text "Log in"'
(9:5): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'And Wait 5 second' (Cucumber::Core::Gherkin::ParseError)
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:34:in `rescue in document'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core/gherkin/parser.rb:28:in `document'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:30:in `block in parse'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `each'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:29:in `parse'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-core-3.2.1/lib/cucumber/core.rb:21:in `compile'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/runtime.rb:75:in `run!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/lib/cucumber/cli/main.rb:34:in `execute!'
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/cucumber-3.1.2/bin/cucumber:9:in `<top (required)>'
C:/Ruby25-x64/bin/cucumber:23:in `load'
C:/Ruby25-x64/bin/cucumber:23:in `<main>'
I've been fighting all day, but I can't understand what the problem is.我整天都在吵架,但我不明白问题出在哪里。 Could you help me?你可以帮帮我吗?
Did you tried to add some tags?您是否尝试添加一些标签?
Feature: Log in to site @Example Scenario: Log in to site on English Given Go to page "http://localhost:3000/login" And Select text "English" in dropdownlist id "lang" And Wait 5 second功能:登录站点@示例场景:以英语登录站点给定 Go 到页面“http://localhost:3000/login”和 Select 文本“English”在下拉列表 id “lang”中等待 5 秒
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.