空手道 UI:如何读取外部文件 (json) 作为测试数据并在文本框中传递值
Karate UI: How to read external file (json) as test data and pass value in textbox
下面是我的功能文件:
Feature: Check test Data
Background:
* configure driver = {type: 'chrome'}
* def testData = read('classpath:src/test/resources/testdata/testfile.json')
Scenario: Verify test data
Given driver 'somevalid-url'
* input('#usernameTextField','testData.TC_001.username')
* input('#passwordTextField','testData.TC_001.password')
在这里,输入文本我正在做 'testData.TC_001.username' 但它不起作用。
请查收附件json:
使用 "testData.testData.TC_001.username"
因为您已经在后台步骤中创建了 "testData"
对象,您必须使用它来访问来自 json 的数据。
不加引号试试:
* input('#usernameTextField', testData.TC_001.username)
首先在您的测试中通过硬编码 JSON 进行实验:
* def testData = { TC_001: { username: 'foo' } }
下面是我的功能文件:
Feature: Check test Data
Background:
* configure driver = {type: 'chrome'}
* def testData = read('classpath:src/test/resources/testdata/testfile.json')
Scenario: Verify test data
Given driver 'somevalid-url'
* input('#usernameTextField','testData.TC_001.username')
* input('#passwordTextField','testData.TC_001.password')
在这里,输入文本我正在做 'testData.TC_001.username' 但它不起作用。
请查收附件json:
使用 "testData.testData.TC_001.username"
因为您已经在后台步骤中创建了 "testData"
对象,您必须使用它来访问来自 json 的数据。
不加引号试试:
* input('#usernameTextField', testData.TC_001.username)
首先在您的测试中通过硬编码 JSON 进行实验:
* def testData = { TC_001: { username: 'foo' } }