While using the developer console in Firefox or Chrome, I noticed that when typing $('a')
, it does not always return an array of all the links on a page as expected. Strange enough, sometimes it only returns a single a
element instead of multiple ones (even though the sites being tested have more than one a
tag). Can anyone shed light on why this inconsistency occurs between different sites and browsers?
This functionality has worked for me in the past without any issues. To illustrate, let's consider
In my testing, the result in the Firefox console shows: https://i.sstatic.net/DZ2dZ.jpg and in Chrome: https://i.sstatic.net/l8tNW.jpg
Interestingly, the CSS Selector works fine on stackoverflow, but not consistently on other sites. However, Xpath seems to work well across all sites.