自动测试Cucumber和Gherkins

Cucumber框架实现自然语言是通过如下方式:通过固定的值取得固定位置参数进行固定的操作。(以下文件只取了部分)

//编写文件 .feature文件
Feature: shopping page
url:https://cuketest.github.io/apps/shopping/index.html

  Background: Open the Index Page
    Given open the url "https://cuketest.github.io/apps/shopping/index.html"

  Scenario: Pay Parking Fee
    When I click "Pagar estacionamento"
    Then I should get the "Pagar Estacionamento" page
    And I click the Número do Ticket
    Then I input keyword "012311241234567" of Número do Ticket
    And I click Cartão de crédito
    Then I input keyword "1234567812345678" of Cartão de crédito
    And I click Vencimento
    Then I input keyword "12" of Vencimento
    And I click Código
    Then I input keyword "20" of Código
    Then I click the button of Pagar
//定义语言页面 js文件//
/ Your step definitions /
// use this.Given(), this.When() and this.Then() to declare step definitions


var { Given, When, Then } = require('cucumber')
let { until } = require('selenium-webdriver')
let { driver } = require('../support/web_driver')
var assert = require('assert')

let defaultuntiltime = 60*1000;
Given(/^open the url "([^"]*)"$/, function (url) {
    return driver.get(url);
});

//scenario Shopping
When(/^I click "([^"]*)"$/, function (arg1) {
    //Pay parking
    let ele = driver.wait(until.elementLocated({ partialLinkText: arg1 }), defaultuntiltime);
    return ele.click();
});

自然语言通常是指一种自然地随文化演化的语言。汉语、英语、日语为自然语言的例子,而世界语则为人造语言,即是一种由人蓄意为某些特定目的而创造的语言。 不过,有时所有人类使用的语言(包括上述自然地随文化演化的语言,以及人造语言)都会被视为“自然”语言,以相对于如编程语言等为计算机而设的“人造”语言。这一种用法可见于自然语言处理一词中。自然语言是人类交流和思维的主要工具。

Cucumber文档:http://cuketest.com/zh-cn/misc/demos.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值