public void selectRestrictedVideo() throws Exception { Reporter.log("Select a Restricted Video from Featured Page."); List<WebElement> webColl = null; while (webColl == null) { webColl = driver.findElements(By.id(restrictedVideo)); if (webColl.size() > 0) { webColl.get(0).click(); break; } else { webColl = null; } SeleniumFunctions.scrollToObject(driver); } }