Karate 空手道UI:如何读取外部文件(json)作为测试数据并在文本框中传递值
下面是我的功能文件:Karate 空手道UI:如何读取外部文件(json)作为测试数据并在文本框中传递值,karate,Karate,下面是我的功能文件: 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'
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' } }
请不要发布代码/错误/数据的图像。而是将代码/错误/数据作为文本发布到代码块中。看见还有,“它不起作用”是什么意思?你能说得更具体一点吗?