question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Karate Embedded Expression not working as expected for xml attribute

See original GitHub issue

This is : 3_PostData_Request.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
    <S:Body>
        <SucceededGetData RequestID="#(request_uuid)">some text</SucceededGetData>
        <MessageDelivered OfferID="#(request_uuid)" />

    </S:Body>
</S:Envelope>

This is the scenario file:

Scenario: test
    * def UUID = function(){ return java.util.UUID.randomUUID() }
    * def request_uuid = call UUID
    * def req = read('classpath:3_PostData_Request.xml')
    * print req

This is the result:

<S:Body>
    <SucceededGetData RequestID="ab5bbb38-d462-42f5-afd2-49c47fd59365">some text</SucceededGetData>
    <MessageDelivered OfferID="#(request_uuid)"/>
  </S:Body>
</S:Envelope>

I would like to know why Karate is able to replace #(request_uuid) for xml element which has some text in it and why not for one without any text. How may I achieve replacement in both the cases seamlessely. I am using karate 0.7.0.1. Thanks !

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
backfloepcommented, Apr 11, 2018

I retestet the szenario of @PallaviMistry and it works with 0.7.0.2

Thanks!

0reactions
ptrthomascommented, Jul 16, 2018

released 0.8.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Karate Embedded Expression not working as expected for xml ...
I would like to know why Karate is able to replace #(request_uuid) for xml element which has some text in it and why...
Read more >
Karate Embedded Expression not working as ... - Stack Overflow
yes this is a bug ! You have a workaround: * set response /Envelope/Body/MessageDelivered/@OfferID = request_uuid.
Read more >
Karate | Test Automation Made Simple.
Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
Read more >
https://raw.githubusercontent.com/intuit/karate/ma...
Feature: xml samples and tests Scenario: xml empty elements and null * def foo ... 2 Scenario: placeholders using xml embedded expressions *...
Read more >
com.intuit.karate.Script.java Source code - Java2s.com
Here is the source code for com.intuit.karate. ... getAsString()); } catch (Exception e) { logger.warn("embedded xml-attribute script eval failed: {}", e.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found