English 中文(简体)
Karate/Gatling: How to read XML file contents as a string from a CSV feeder variable?
原标题:

The value of order_contents is passed from a CSV file defined in scala file. order_contents in the CSV file is defined as "read( classpath:data/XML-Order.txt )" XML-Order.txt contains a string that is in XML format. Due to some limitations, I want to read it as string. :)

Feature: checkOrder

 Background:
 Given url getOrder.URL
 * def contents = __gatling.order_contents

@checkOrder
 Scenario: checkOrder
* string orderContents = contents
* print orderContents

When running, the print statement shows only read( classpath:data/XML-Order.txt ) as a string but not the contents of the string

BUT By hardcoding the path, it will achieve the result as what I have expected.

Feature: checkOrder

 Background:
 Given url getOrder.URL
 * def contents = __gatling.order_contents

@checkOrder
 Scenario: checkOrder
* string orderContents = read( classpath:data/XML-Order.txt )
* print orderContents

When running, the print statement will shows the XML string that is in XML-Order.txt file.

Also tried to do this

 * def test = <contents>
 * string value = test

But I am getting the below error when printing org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 24; XML document structures must start and end within the same entity.

But I want to implement a more dynamic way of defining the data via CSV file. Any help is appreciated.

问题回答

暂无回答




相关问题
How do I get karate-gatling example project to compile?

I downloaded the karate-gatling example project from here: https://github.com/karatelabs/karate/tree/master/karate-gatling I opened the project in IntelliJ and ran the following command: mvn clean ...

Reading Data with from csv file in Karate

Below is the data, I have maintained in the csv file Data "[{ label : Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into ...

Conditional logic for Karate UI

I am trying to add a conditional logic for karate UI feature that I am trying to build. The requirement is this: There are 5 fields; select(‘select[id=currency]’, ‘EUR’) // has a random logic to ...

热门标签