You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@BogdanLivadariu Same question could be asked for URLs. Language is most often set as sub-domain, first part of the path, or as query param. In my experience, on dynamic pages, the URLs change more often than texts.
Having links defined by text would be much easier to maintain whenever the pages change. Imagine your Selenium telling you that a link with URL www.example.com/order/invoices-cust0031?filter=by-date&sid=168754678&order=date cannot be found on page. You would need to know what that URL means or meant and if it has changed. On the other hand, imagine Selenium telling you that a link with text "show invoices" cannot be found. In this case, only domain knowledge is required and you can easily check the current page for a link with similar sounding text.
There are two problems with my suggestion, though:
What about links with an image inside?
What if multiple links have the same text? (e.g. "show more" or "expand")
In many dynamic applications the link targets change with query params because of session IDs, JavaScript, search params etc.
I think, in most cases it would be better to locate anchors by their containing text (or at least the first words of it) using XPath.
The text was updated successfully, but these errors were encountered: