我正在使用我的Mac OS X盒子上的Rails和Cucumber.当我尝试运行以下方案时:
Feature: ActorDetail
In order to learn about an actor
As a costumer
I want to see their details
Scenario: Actors page should exist
Given I am on actor page
Then I should see "Actors"
Run Code Online (Sandbox Code Playgroud)
当我尝试运行测试时,我得到以下内容:
kevin:11:17 PM:~/Documents/Rails/testApp: cucumber
Using the default profile...
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement
F--F
Failing Scenarios:
cucumber features/ActorDetail.feature:6 # Scenario: Actors page should exist
1 scenario (1 failed)
2 steps (2 skipped)
0m0.138s …
Run Code Online (Sandbox Code Playgroud) 我有一个有这个的表格
<%= submit_tag 'Search Event' %>
和黄瓜一步说
And I should see "Search Event"
但是这一步失败了......为什么会这样?
这是我得到的错误
expected #has_content?("Search Event") to return true, got false (RSpec::Expectations::ExpectationNotMetError)
Run Code Online (Sandbox Code Playgroud) 我有这个代码:
Given /^I wait for (\d+) seconds$/ do |seconds|
$webClient.wait(seconds)
end
Then /^I wait for (\d+) seconds$/ do |seconds|
$webClient.wait(seconds)
end
Run Code Online (Sandbox Code Playgroud)
我可以用一种覆盖THEN和GIVEN的方法以某种方式定义它吗?
谢谢
我正在使用selenium-webdriver和ruby中的黄瓜自动化网站的测试用例.我需要每个功能以特定顺序运行并使用相同的浏览器窗口.Atm的每个功能都会创建一个新的窗口来运行测试.虽然在某些测试用例中需要这种行为 - 但在许多情况下并非如此.从我到目前为止的研究来看,似乎有关于在整个测试案例中是否可以用硒驱动相同浏览器窗口的混合答案.我遇到的大多数答案都是针对其他语言的,并且是针对浏览器特定的解决方法(我在测试IE时开发我的测试,但预计会在其他浏览器中运行这些测试).我在Ruby工作,从我所看到的,似乎我必须为该页面创建一个类?我很困惑为什么我必须这样做或如何帮助.
我的env.rb文件:
require 'selenium-webdriver'
require 'rubygems'
require 'nokogiri'
require 'rspec/expectations'
Before do
@driver ||= Selenium::WebDriver.for :ie
@accept_next_alert = true
@driver.manage.timeouts.implicit_wait = 30
@driver.manage.timeouts.script_timeout = 30
@verification_errors = []
end
After do
#@driver.quit
#@verification_errors.should == []
end
Run Code Online (Sandbox Code Playgroud)
到目前为止,我收集了一些有类似问题的人的信息:https : //code.google.com/p/selenium/issues/detail?id = 18 有没有办法将已运行的浏览器附加到java中的selenium webdriver ?
如果我的问题不明确,请问我问题.我有更多的测试要创建,但如果我的基础很草率并且缺少所请求的功能,我不想继续创建测试.(如果您发现我的代码中有任何其他问题,请在评论中指出)
如何在页面对象类中使用Rspec期望.我需要断言元素.目前我正在使用xpath,其他定位器来检查元素是否存在.我知道使用它是步骤定义.但我需要在课堂上.
class AssertTest
include PageObject
span(:success, text: "Message added successfully")
def assert_element
success_element.when_present (or) success?
# I need to use Rspec expectations instead
# continue...
end
end
Run Code Online (Sandbox Code Playgroud)
在步骤定义中,我可以像以下一样使用它:
@current_page.text.should include "message"
Run Code Online (Sandbox Code Playgroud) 我正在使用黄瓜和慢手宝石.我发现即使我使用来自slowhandcuke repo的字符串,它也不会使用示例表格式化方案的大纲:
cucumber --format 'Slowhandcuke::Formatter'
Run Code Online (Sandbox Code Playgroud)
标准黄瓜--format pretty
也没有任何效果.你有任何可能导致这个问题的想法吗?
我正在尝试添加一个.feature文件,以便在intellij的java套件中进行测试.Howerver我无法在intellij中打开文件
黄瓜支持仅适用于终极版吗?
编辑:我刚刚完成了全新安装,现在正在运行
当我用Cucumber运行我的第一个测试文件时,我得到了这个例外如何解决这个问题?
Exception in thread "main" cucumber.runtime.CucumberException: Error parsing feature file D:/intalled/CucumberConcepts/src/cucumber/features/myfeature.feature
at cucumber.runtime.FeatureBuilder.parse(FeatureBuilder.java:123)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:52)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:33)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:143)
at cucumber.runtime.Runtime.run(Runtime.java:107)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:16)
Run Code Online (Sandbox Code Playgroud)
引起:gherkin.lexer.LexingError:第1行的Lexing错误:'功能:我的框架工作的概念证明
Feature : Proof of concept that my framework works
Scenario Outline : My first Test
Given this is my first test
When This is my second step
Then This is the final step
Run Code Online (Sandbox Code Playgroud) 用户操作后,Web应用程序始终使用此div.我的测试脚本有这一行.逐字逐句.
@browser.div(:id => 'loading-indicator').wait_while_present
Run Code Online (Sandbox Code Playgroud)
在任何地方明确地包括这条线是可以的,但是丑陋和重复.
使用wait_until_present
与下一元素(" foo
负载指示后"),有时会工作.然而,在某些情况下foo
和负载指示同时存在,但foo
不是visible?
直到负载指示消失.
有没有办法,或许在env.rb
,向watir-webdriver表明它应该始终wait_while
存在这个元素?
我必须使用Java黄瓜来编写BDD测试,我想从示例表的每一行中解析一个整数列表,然后使用最新版本的Cucumber(4.2.6)将此列表传递给我的step方法。因此,我在功能文件中获得了以下步骤定义:
Scenario Outline: Some scenarion
Given a list of integer: <integer_list>
Examples:
| integer_list |
| 2, 3, 5, 6 |
| 3, 12, 45, 5, 6|
Run Code Online (Sandbox Code Playgroud)
我的代码中需要这样的内容:
@Given("a list of integer: (\\d+.)")
public void storeIntegerList(List<Integer> integers) {
System.out.println(integers.size());
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,我找不到一种将这些值解析为列表的方法。要么找不到step方法(我尝试过很多不同的正则表达式),要么抛出异常,通知我我的数字无法转换为列表。
解决方法是将列表解析为字符串,然后将其拆分。但是,我无法想象在2019年没有更好的方法可以做到这一点。
解决方法:
Scenario Outline: Some scenarion
Given a list of integer: "<integer_list>"
Examples:
| integer_list |
| 2, 3, 5, 6 |
| 3, 12, 45, 5, 6|
@Given("a list of integer: {string}")
public void storeIntegerList(String integers) {
List<String> …
Run Code Online (Sandbox Code Playgroud) cucumber ×10
ruby ×4
bdd ×2
cucumber-jvm ×2
java ×2
eclipse ×1
formatting ×1
gherkin ×1
pageobjects ×1
rspec ×1
selenium ×1
watir ×1