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();
});
自然語言通常是指一種自然地隨文化演化的語言。漢語、英語、日語爲自然語言的例子,而世界語則爲人造語言,即是一種由人蓄意爲某些特定目的而創造的語言。 不過,有時所有人類使用的語言(包括上述自然地隨文化演化的語言,以及人造語言)都會被視爲“自然”語言,以相對於如編程語言等爲計算機而設的“人造”語言。這一種用法可見於自然語言處理一詞中。自然語言是人類交流和思維的主要工具。