Reputation: 21
Imagine an element of page element like this:
link(:upgrade_link, id: 'Upgrade')
Now, imagine that the Id of this link has a chance of changing in each test, to a different id : difference.
Is it possible to make something like this?
link(:upgrade_link, id: 'Upgrade' || id: 'difference')
Upvotes: 0
Views: 96
Reputation: 21
I ve found another solution:
link(:upgrade_link, xpath:"//a[@id = 'Upgrade' or @id = 'difference']")
Upvotes: 0
Reputation: 46836
To match multiple possible ids, you could match the id by regexp. The regexp allows for multiple matching by using the |
.
Your page object accessor would be:
link(:upgrade_link, id: /^(Upgrade|difference)$/)
Note that the ^
and $
are used to ensure that the id exactly matches. Without them, you would match links with ids like 'Upgrade2', 'adifferenceb', etc.
Upvotes: 2