List of usage examples for org.openqa.selenium ElementNotVisibleException ElementNotVisibleException
public ElementNotVisibleException(String message, Throwable cause)
From source file:org.alfresco.po.share.search.SearchResultItem.java
License:Open Source License
/** * Method to Click on viewInBrowser link of result item present on search results. * Note : This thumbnail css used in this method works only on chrome browser. * //from ww w . j ava2 s . c om * @return String, url of the current window. */ public String clickOnViewInBrowserIcon() { WebElement viewInBrowser; String mainWindow; Set<String> windows; String newTab; String url; RenderTime timer = new RenderTime(10000); try { WebElement thumbnail = webElement.findElement(By.cssSelector(THUMBNAIL_LINK)); mouseOver(thumbnail); while (true) { viewInBrowser = webElement.findElement(By.cssSelector(VIEW_IN_BROWSER_LINK)); try { timer.start(); if (viewInBrowser.isDisplayed()) { mainWindow = driver.getWindowHandle(); viewInBrowser.click(); windows = driver.getWindowHandles(); windows.remove(mainWindow); newTab = windows.iterator().next(); driver.switchTo().window(newTab); url = driver.getCurrentUrl(); driver.close(); driver.switchTo().window(mainWindow); return url; } } catch (NoSuchWindowException ne) { } catch (ElementNotVisibleException e) { } finally { timer.end(); } } } catch (ElementNotVisibleException e) { throw new ElementNotVisibleException("View in browser link is not visible in Search Results Item", e); } }