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