質問

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')
役に立ちましたか?

解決

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.

他のヒント

I ve found another solution:

link(:upgrade_link, xpath:"//a[@id = 'Upgrade' or @id = 'difference']")
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top