Forum Discussion

NSeibert's avatar
NSeibert
Contributor
15 years ago

[Resolved] Case sensitive xpath result

Not sure what the approach here should be for my assertion
XPath Expression =
//html[1]/body[1]/div[2]/div[4]/div[1]/div[1]/form[1]/div[1]/div[2]/div[1]/table[1]/tbody[1]/tr[1]/td[2]/a[1]/text()
returns
00:00:00:00:01:B1
Expected Result =
${#Project#mac-addr} which evaluates to 00:00:00:00:01:b1
There are no options in the particular 'XPath Match Configuration' assertion to do a case insensitive compare. (IE The 'contains' assertion has this option.)

How might I make this comparison case insensitive?

Thank you for your help
  • William_Willafo's avatar
    William_Willafo
    Occasional Contributor
    I think you can use the Translate function:

    //html[1]/body[1]/div[2]/div[4]/div[1]/div[1]/form[1]/div[1]/div[2]/div[1]/table[1]/tbody[1]/tr[1]/td[2]/a[1]/translate(text(), "ABCDEF", "abcdef")

    Haven't been able to try this out so I'm not positive the syntax is correct.
  • Thank you for your help William. It looks like this will work for the case where a 00:00:00:00:01:B1 is returned and then validated with the lower 00:00:00:00:01:b1. And for my usage this is a good solution. MAC addresses lookups \ queries are typically case (Lower vs Upper) insensitive. If the case is reversed this will fail 00:00:00:00:01:B1 or 00:00:00:00:01:b1 is returned but the validation value happens to be 00:00:00:00:01:B1.

    The lower case is now expected. - 00:00:00:00:01:b1.

    Is there a similar option to force the expected comparison string to a lower \ upper?

    Thanks again for your help.