Optimizing finding multiple elements by id by using CSS selectors if available. Fixes issue 7682