List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.callimachusproject.webdriver.helpers.BrowserFunctionalTestCase.java
License:Apache License
private String getBrowserName() { String name = getName();//from ww w. j ava 2s . co m if (name == null) { Map<String, RemoteWebDriverFactory> map = getInstalledWebDrivers(); if (map.isEmpty()) throw new WebDriverException("No WebDrivers installed"); return map.keySet().iterator().next(); } return name.substring(name.lastIndexOf(DELIM) + 1); }
From source file:org.eclipse.ecr.testlib.runner.web.WebPage.java
License:Open Source License
public void to(String path) { if (path.contains("://")) { driver.get(path);//www . jav a 2s . c om } else { try { URL url = new URL(new URL(config.home), path); driver.navigate().to(url); } catch (MalformedURLException e) { throw new WebDriverException(e); } } }
From source file:org.fluentlenium.core.Fluent.java
License:Apache License
/** * Take a snapshot of the browser into a file given by the fileName param. * * @param fileName//from w ww . j a v a 2 s.c o m */ public Fluent takeScreenShot(String fileName) { if (!(getDriver() instanceof TakesScreenshot)) { throw new WebDriverException("Current browser doesn't allow taking screenshot."); } File scrFile = ((TakesScreenshot) getDriver()).getScreenshotAs(OutputType.FILE); try { File destFile = new File(fileName); FileUtils.copyFile(scrFile, destFile); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException("error when taking the snapshot", e); } return this; }
From source file:org.jboss.arquillian.graphene.angular.findby.ByAngularImpl.java
License:Apache License
@Override public List<WebElement> findElements(SearchContext searchContext) { AngularSearchContext angularSearchContext = getSearchContext(getGrapheneContext(searchContext)); List<WebElement> elements; try {//w w w.ja v a 2s .c o m if (searchContext instanceof WebElement) { elements = angularSearchContext.findElementsInElement(selector, (WebElement) searchContext); } else if (searchContext instanceof WebDriver) { elements = angularSearchContext.findElements(selector); } else { // Unknown case throw new WebDriverException( "Unable to determine the SearchContext passed to findBy method! It is not an instance of WebDriver or WebElement. It is: " + searchContext); } } catch (Exception e) { throw new WebDriverException("Unable to locate " + elementNames + " element(s) for: " + selector + ". Check whether it is correct", e); } return elements; }
From source file:org.jboss.arquillian.graphene.angular.findby.ByModelImpl.java
License:Apache License
@Override public List<WebElement> findElements(SearchContext searchContext) { GrapheneContext grapheneContext = getGrapheneContext(searchContext); AngularModelSearchContext modelSearchContext = JSInterfaceFactory.create(grapheneContext, AngularModelSearchContext.class); List<WebElement> elements; try {/*w w w .j a v a 2s . c o m*/ if (searchContext instanceof WebElement) { elements = modelSearchContext.findElementsInElement(modelName, (WebElement) searchContext); } else if (searchContext instanceof WebDriver) { elements = modelSearchContext.findElements(modelName); } else { // Unknown case throw new WebDriverException( "Unable to determine the SearchContext passed to findBy method! It is not an instance of WebDriver or WebElement. It is: " + searchContext); } } catch (Exception e) { throw new WebDriverException( "Unable to locate ng-model element for: " + modelName + ". Check whether it is correct", e); } return elements; }
From source file:org.jboss.arquillian.graphene.enricher.findby.ByJQuery.java
License:Open Source License
@Override public List<WebElement> findElements(SearchContext context) { GrapheneContext grapheneContext = ((GrapheneProxyInstance) context).getContext(); JQuerySearchContext jQuerySearchContext = JSInterfaceFactory.create(grapheneContext, JQuerySearchContext.class); List<WebElement> elements; try {/* w w w.j a va2 s . com*/ // the element is referenced from parent web element if (context instanceof WebElement) { elements = jQuerySearchContext.findElementsInElement(jquerySelector, (WebElement) context); } else if (context instanceof WebDriver) { // element is not referenced from parent elements = jQuerySearchContext.findElements(jquerySelector); } else { // other unknown case throw new WebDriverException( "Cannot determine the SearchContext you are passing to the findBy/s method! It is not instance of WebDriver nor WebElement! It is: " + context); } } catch (Exception ex) { throw new WebDriverException( "Can not locate element using selector " + jquerySelector + " Check out whether it is correct!", ex); } return elements; }
From source file:org.jboss.arquillian.graphene.findby.ByJQueryImpl.java
License:Open Source License
@Override public List<WebElement> findElements(SearchContext searchContext) { GrapheneContext grapheneContext = getGrapheneContext(searchContext); JQuerySearchContext jQuerySearchContext = JSInterfaceFactory.create(grapheneContext, JQuerySearchContext.class); List<WebElement> elements; try {/*from w ww .j a va2 s. c o m*/ // the element is referenced from parent web element if (searchContext instanceof WebElement && !isReferencedFromRootOfDocument()) { elements = jQuerySearchContext.findElementsInElement(selector, (WebElement) searchContext); } else if (searchContext instanceof WebDriver || isReferencedFromRootOfDocument()) { // element is referenced from root of document elements = jQuerySearchContext.findElements(selector); } else { // other unknown case throw new WebDriverException( "Cannot determine the SearchContext you are passing to the findBy/s method! It is not instance of WebDriver nor WebElement! It is: " + searchContext); } } catch (Exception ex) { throw new WebDriverException( "Can not locate element using selector " + selector + " Check out whether it is correct!", ex); } return elements; }
From source file:org.nuxeo.functionaltests.LogTestWatchman.java
License:Open Source License
public File dumpPageSource(String filename) { if (driver == null) { return null; }/*from w ww.j a v a2s.c o m*/ FileWriter writer = null; try { String location = System.getProperty("basedir") + File.separator + "target"; File outputFolder = new File(location); if (!outputFolder.exists() || !outputFolder.isDirectory()) { outputFolder = null; } File tmpFile = File.createTempFile(filename, ".html", outputFolder); log.trace(String.format("Created page source file named '%s'", tmpFile.getPath())); writer = new FileWriter(tmpFile); writer.write(driver.getPageSource()); return tmpFile; } catch (IOException e) { throw new WebDriverException(e); } finally { IOUtils.closeQuietly(writer); } }
From source file:org.nuxeo.functionaltests.pages.tabs.ArchivedVersionsSubPage.java
License:Open Source License
/** * Removes the selected versions./* ww w .j a va2 s . c o m*/ * * @return the archived versions sub page */ public ArchivedVersionsSubPage removeSelectedVersions() { ArchivedVersionsSubPage archivedVersionsPage = null; // As accepting the Delete confirm alert randomly fails to reload the // page, we need to repeat the Delete action until it is really taken // into account, ie. the "Delete" button is not displayed any more nor // enabled. Clock clock = new SystemClock(); long end = clock.laterBy(AbstractTest.LOAD_TIMEOUT_SECONDS * 1000); while (clock.isNowBefore(end)) { try { archivedVersionsPage = executeActionOnSelectedVersions(DELETE_ACTION_ID, true, ArchivedVersionsSubPage.class, AbstractTest.LOAD_SHORT_TIMEOUT_SECONDS * 1000, AbstractTest.AJAX_TIMEOUT_SECONDS * 1000); } catch (NotFoundException nfe) { if (archivedVersionsPage == null) { break; } return archivedVersionsPage; } try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } } throw new WebDriverException("Couldn't remove selected versions"); }
From source file:org.nuxeo.functionaltests.ScreenShotFileOutput.java
License:Open Source License
@Override public File convertFromPngBytes(byte[] data) { FileOutputStream fos = null;//from ww w . ja v a2 s . co m try { String location = System.getProperty("basedir") + File.separator + "target"; File outputFolder = new File(location); if (!outputFolder.exists() || !outputFolder.isDirectory()) { outputFolder = null; } File tmpFile = File.createTempFile(screenshotFilePrefix, ".png", outputFolder); log.trace(String.format("Created screenshot file named '%s'", tmpFile.getPath())); fos = new FileOutputStream(tmpFile); fos.write(data); return tmpFile; } catch (IOException e) { throw new WebDriverException(e); } finally { IOUtils.closeQuietly(fos); } }