I've come across cases when there are lots of links on the page and the following xpath works for choosing the first one:
//tag[@...]/div/a[1]
There are other cases when the above xpath doesn't work and then I need to use it the following way:
(//tag[@...]/div/a)[1]
As I write lengthier xpaths to code in business logic for which elements to select, this difference starts getting all the more complicated where the same xpath has multiple combinations of both of these.
What is the difference exactly between writing xpaths in these two ways? I've seen that for any particular occasion one of them works and the other doesn't.