【发布时间】:2017-05-16 22:56:53
【问题描述】:
我正在按照教程运行我的第一个 Cucumber 脚本:
Feature: guru99 Demopage Login
In order to Login in Demopage we have to enter login details
Scenario:
Register On Guru99 Demopage without email
Given I am on the Guru99 homepage
When enter blank details for register
Then error email shown
我在 Idea 中有项目,但运行时出现错误。
使用 chrome 时:
Failed to open TCP connection to 127.0.0.1:9515 (No connection could be made because the target machine actively refused it.
我不知道如何解决它。
使用 Firefox 时,脚本成功打开浏览器但之后失败:
require 'watir'
require 'colorize'
Selenium::WebDriver::Firefox::Binary.path='C:\soft\Mozilla Firefox\firefox.exe'
case ENV['BROWSER']
when 'chrome'
browser = Watir::Browser.new :chrome
when 'firefox'
browser = Watir::Browser.new :firefox
end
Given(/^I am on the Guru99 homepage$/)do
@browser = Watir::Browser.new :firefox
@browser.goto "http://demo.guru99.com"
end
When(/^enter blank details for register$/) do
browser.text_filed(:name,"emaiid").set("")
browser.button(:name,"btnLogin").click
end
Then(/^error email shown$/) do
puts "Email is Required!".red
browser.close
end
然后返回:
NoMethodError: undefined method `text_filed' for nil:NilClass
在这一行:
browser.text_filed(:name,"emaiid").set("")
我发现了一些我需要编写一个类来调用方法的参考资料。我试过但没有成功。
【问题讨论】:
-
"How To s The Smart Way" 将对您有用。 “我需要写一个类来调用一个方法。我试过了,但没有成功。”它在哪里?为什么没有成功?请阅读“minimal reproducible example”和“How much research effort is expected of Stack Overflow users?”
标签: ruby google-chrome firefox methods cucumber