Minor optimization: store type attribute in variable so we don't have to call WebDriver API for it twice