Tag: 黄瓜

黄瓜testing通过没有function存在

我已经开始为Cucumber创build一个Meteor应用程序的testing套件( http://joshowens.me/cucumber-js-and-meteor-the-why-and-how-of-it/ )。 一些testing通过时没有任何function。 例如,testing文件login.feature包含Feature: Allow users to login , Scenario: A user can login with valid information When I click on sign in link 它在文件loginSteps.js被支持: this.When(/^I click on sign in link$/, function (callback) { helper.world.browser. waitForExist('.at-signup', 7000). waitForVisible('.at-signup'). click('.at-signup'). call(callback); }); loginbutton实际上有class="btn btn-default navbar-btn" ,但Velocity说testing通过了858ms。 另一个testing通过url(helper.world.cucumber.mirror.rootUrl + "event/1")虽然没有这样的url。 其他testing失败,但是,如: getText('.user-menu .dropdown-top-level', function (err, username) […]

如何设置黄瓜环境variables

我有以下package.json: { "name": "newcucumber", "version": "1.0.0", "main": "index.js", "scripts": { "test": "./node_modules/.bin/cucumber-js", "firefox": "./node_modules/.bin/cucumber-js — –profile.desktop.env.browser ff" }, "author": "", "license": "ISC", "dependencies": { "chromedriver": "^2.24.1", "cucumber": "^1.3.0", "firefox-profile": "^0.4.2", "geckodriver": "^1.1.2", "phantomjs-prebuilt": "^2.1.12", "selenium-webdriver": "^3.0.0-beta-2" } } 我运行程序使用: npm test 我想为黄瓜设置一个环境variables,以便我可以从命令行运行: npm test firefox或者npm test phantomjs 。 它也可以作为package.json“脚本”的一部分,如上所述,但我不确定是否正确。 调用npm run-script firefox 如何实现它,以便在js代码中,像world.js或browser.js,我抓住envvariables?

xpath上去父母,然后回到孩子

<div class="classA"> <label class="classB"> <span>Referral Date</span> </label> <div> <input class="classC"> </div> </div> 我正在使用xpath来抓取'推荐date'。 这是一个要求,因为用户将传递这个人类可读标签给我。 我知道如何到达那里: //div/label[@class="classB"]/span[text()="Referral Date"] 现在,我需要访问input[@ class =“classC”],以在我的WebDriver自动化中点击它。 我可以做这样的事吗? //div/label[@class="classB"]/span[text()="Referral Date"] /parent::div/div/input[@class="classC"] 那么,这不适合我。 我也试过这个没成功: //div/label[@class="classB"]/span[text()="Referral Date"] /following-sibling::div/input[@class="classC"] 没有工作,我不认为它可以因为跟随兄弟姐妹只是指内的节点。 对?

使用黄瓜来testing一个不用rails写的API

我正在编写一个使用非rails框架的API。 我通常使用Cucumber作为BDD,并在我写入RAILS时testingAPI。 当我testing一个写在node.js(或任何其他框架,顶部)上的API时,有没有强烈的理由不使用Cucumber? 强烈的技术原因不这样做可能包括: 黄瓜对铁路的依赖性 node.js存在一个更好的框架 我不知道的其他一些技术原因。

在多个浏览器上运行testing(按顺序)

我目前只使用Chrome(驱动程序)进行testing。 我想用Firefox和Safari来testing它。 一个接一个,不能并行。 这是我开始testing的重要任务: gulp.task('test', function() { return gulp.src('*test/features/*').pipe(cucumber({ 'steps': '*test/features/steps/*.js' })); }); 一个简单的function文件: Feature: UI Testing UI Scenario: Check the title of the page When I open the homepage Then I should see "Test – IntApp" in the title 和步骤文件: const chrome = require('selenium-webdriver/chrome'); const webdriver = require('selenium-webdriver'); const assert = require('assert'); module.exports = […]

Cucumber.js多次执行相同的场景

我创build了以下function: Feature: Performing a test Scenario: Do test Given Situation X When Y occures Then Z should be checked 它作为单个testing存储在一个function文件中。 现在我希望能够多次执行场景 基于指示场景需要执行多less次的参数。 根据时间安排,情景应该重复多久。

在testingnodeJS应用程序时,应该如何设置Capybara.app?

我已经看到了一百万次: 如果你不使用Rails的话… require 'capybara/cucumber' Capybara.app = MyRackApp 但是如果你想testing一个node.js express v4应用程序什么是“MyRackApp”? 感谢您的回应

通过Node.js路由http请求

我试图做一个黄瓜testing设置与Node.js可以testing任何网站通过使用iframe。 通常iframe是一个不行,因为跨脚本的安全限制。 但是,如果可能的话(我确定是这样的,而且我相信你会想出一个解决scheme),当请求一个特定的url名称时,通过请求的url获取testing的目标网站,这样iframe将被加载一个testing目标的副本。 基本上只是一个标准的node.js服务器,根据req.url获取特定的页面,类似于一个地址请求路由器。 这是我公然的尝试做到这一点。 通过获取testing页面。 该url的作品。 但我有问题从http服务器切换到连接对象。 有没有办法“喂”与http服务器响应的连接? PS。 我还创build了两个node.js服务器的解决scheme。 节点1获取testing目标并将其与黄瓜testing页面混合。 节点2主持黄瓜testing。 此解决scheme正在工作。 但是它会在发生JavaScript命名冲突的网站上产生问题。 这就是为什么通过封装解决这个问题的iframe解决scheme更具吸引力。 var http = require('http'); var connect = require('connect'); var port = process.env.PORT || 8788; var server = http.createServer(function(req, webres) { var url = req.url; console.log(url); if(url == '/myWebsiteToBeTestedWithCucumberJS') { // Load the web site to be tested "myWebsiteToBeTestedWithCucumberJS" // […]

Node.js BDD。 黄瓜,小黄瓜或黄瓜?

我想开始使用BDD为我的一个Node.js项目。 查看Node.js wiki,我发现至less有3个模块: 黄瓜 , 小黄瓜和黄瓜 ,都支持小黄瓜语言。 你推荐哪些?