Fixed authentication error and updated logic to get elements by attribute.