jack ryan
jack ryan

Reputation: 59

Using the OR logical function in the "starts with" condition for finding the xpath

I use the following X-path to extract a web element based on the starts-with condition

//a[starts-with(@href,'https://test-abc-eu.softcore.com')]

I want to increase the scope of the search by adding a logical OR condition to the search. Anything that starts with

//a[starts-with(@href,'https://test-abc-eu.softcore.com')]
//a[starts-with(@href,'https://test-abc.softcore.com')]

Something like

//a[starts-with(@href,'https://test-abc-eu.softcore.com' or @href,'https://test-abc.softcore.com')]

Is this possible? Any help would be appreciated. Thanks.

Upvotes: 0

Views: 76

Answers (1)

Dmitri T
Dmitri T

Reputation: 168122

The correct syntax would be:

//a[starts-with(@href,'http://test-abc.softcore.com') or starts-with(@href,'https://test-abc-eu.softcore.com')]

Demo:

enter image description here

As you can see both links are matched.

References:

Upvotes: 1

Related Questions