0 votes
1 view
in RPA by (12.8k points)

Hi All,

I am trying to write the relative expression(XPath) to get the card details from the following website

https://www.fakenamegenerator.com/gen-random-us-us.php

I see that the card name keeps alternating between VISA and MasterCard,

I wanted to know if the following expression is possible

"//dl[dt/text()='MasterCard']/dd OR //dl[dt/text()='Visa']/dd"

Can I use OR operator to make the expression generic so that it will work for both the cases VISA or Master Card?

FYI this is for an Automation Anywhere project where I am practicing to enhance my skills in WEB Automations

1 Answer

0 votes
by (29.8k points)

You cannot use the or operator like that. It is used when you want to have multiple predicate conditions. If you would like to have multiple possible node results like in your example then you should use a pipe | operator

//dl[dt/text()='MasterCard']/dd | //dl[dt/text()='Visa']/dd

 Using the pipe operator basically means that you are doing multiple searches rather than a single complex one.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...