Forum Discussion

apandit's avatar
apandit
Occasional Contributor
13 years ago

How to trim white space in xpath assertion

I am using excel data source that contains white space at the end of the value. The assertion is as below

${DataSource#Phone}

What do I need to do to remove trailing white space?

Thanks,
  • two workarounds-

    1. why dont u try removing space from phone number end?
    2. ${DataSource#Phone }

    Let me know your feedback,

    ^Best regards
  • apandit's avatar
    apandit
    Occasional Contributor
    I appreciate your reply.

    1. I could remove white space from the data but it is manual work and I have to do it for lot of other fields everytime we get test file.

    2. I had posted incorrect image. The correct assertion file attached.

    Thanks,
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    This will remove leading and trailing spaces:

    ${=context.expand('${DataSource#Phone}').trim()}