Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karate Embedded Expression not working as expected for xml attribute #341

Closed
PallaviMistry opened this issue Mar 7, 2018 · 7 comments
Closed
Assignees
Milestone

Comments

@PallaviMistry
Copy link

PallaviMistry commented Mar 7, 2018

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 !

@ptrthomas ptrthomas self-assigned this Mar 8, 2018
@ptrthomas ptrthomas added the bug label Mar 8, 2018
@ptrthomas ptrthomas added this to the v0.7.1 milestone Mar 8, 2018
@ptrthomas ptrthomas added the fixed label Mar 8, 2018
@ptrthomas
Copy link
Member

@PallaviMistry yes this is a bug ! You have a workaround:

* set response /Envelope/Body/MessageDelivered/@OfferID = request_uuid

@PallaviMistry
Copy link
Author

Thanks for the quick response. Thanks !

@ptrthomas
Copy link
Member

@PallaviMistry great, I'll keep this open until a formal 0.7.0 release.

can you also mark the StackOverflow question as accepted / upvote ?

@ptrthomas ptrthomas reopened this Mar 8, 2018
@PallaviMistry
Copy link
Author

Done !
The workaround solves my problem, however I wanted to avoid writing xpath in my scenario. No worries, I saw you fixed the issue in 0.7.1 version. Will wait for it to be available in maven.
Also for others help, there is one more workaround I used: In scenarioFile: * replace req.${request_uuid} = request_uuid And in xml I changed : OfferID="#(request_uuid)" to OfferID="${request_uuid}"

@ptrthomas
Copy link
Member

@PallaviMistry there is a 0.7.0.2 version available for you to try.

@backfloep
Copy link

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

Thanks!

@ptrthomas
Copy link
Member

released 0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants