List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:org.uiautomation.ios.inspector.controllers.IDEController.java
License:Apache License
private String extractSession(String pathInfo) { if (pathInfo.startsWith("/session/")) { String tmp = pathInfo.replace("/session/", ""); if (tmp.contains("/")) { return tmp.split("/")[0]; } else {// w ww. j a v a 2s . c o m return tmp; } } else { throw new WebDriverException("cannot extract session id from " + pathInfo); } }
From source file:org.uiautomation.ios.inspector.controllers.NotImplementedIDEController.java
License:Apache License
public View handle(HttpServletRequest req) { System.err.println("no controller for that " + req.getPathInfo()); // return new DefaultView(getModel()); throw new WebDriverException("no controller for " + req.getPathInfo()); }
From source file:org.uiautomation.ios.inspector.controllers.ResourceController.java
License:Apache License
public View handle(HttpServletRequest req) { String path = req.getPathInfo(); String pattern = "/resources/"; int end = path.indexOf(pattern) + pattern.length(); String resource = path.substring(end); InputStream is = null;//from w ww.j a v a 2 s. com if (resource.endsWith("screenshot.png")) { String session = extractSession(req.getPathInfo()); IDESessionModel model = cache.getModel(new Session(session)); try { is = model.getScreenshot(); } catch (FileNotFoundException e) { is = null; } } else { is = IDEServlet.class.getResourceAsStream("/" + resource); } String mime = getMimeType(resource); if (is == null) { throw new WebDriverException("error getting resource " + req.getPathInfo() + req.getQueryString()); } return new ResourceView(is, mime); }
From source file:org.uiautomation.ios.inspector.controllers.ResourceController.java
License:Apache License
private String getMimeType(String resource) { if (resource.endsWith(".png")) { return "image/png"; } else if (resource.endsWith(".css")) { return "text/css"; } else if (resource.endsWith(".js")) { return "application/x-javascript"; } else if (resource.endsWith(".jpg")) { return "image/jpeg"; } else if (resource.endsWith(".gif")) { return "image/gif"; }/*from w w w .j a va 2s. co m*/ throw new WebDriverException("mime type NI" + resource); }
From source file:org.uiautomation.ios.inspector.controllers.ResourceController.java
License:Apache License
private String extractSession(String pathInfo) { if (pathInfo.startsWith("/resources/session/")) { String tmp = pathInfo.replace("/resources/session/", ""); if (tmp.contains("/")) { return tmp.split("/")[0]; } else {/*from w ww. j a va 2 s. c o m*/ return tmp; } } else { throw new WebDriverException("cannot extract session id from " + pathInfo); } }
From source file:org.uiautomation.ios.inspector.controllers.SessionGuesserController.java
License:Apache License
private Session getSession() throws Exception { HttpClient client = HttpClientFactory.getClient(); String url = cache.getEndPoint() + "/status"; URL u = new URL(url); BasicHttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("GET", url); HttpHost h = new HttpHost(u.getHost(), u.getPort()); HttpResponse response = client.execute(h, r); JSONObject o = Helper.extractObject(response); String id = o.optString("sessionId"); if (id == null) { throw new WebDriverException("cannot guess the sessionId for the IDE to use."); }/*from w w w. j a v a 2s .com*/ return new Session(id); }
From source file:org.uiautomation.ios.inspector.Model.java
License:Apache License
public void setDriver(RemoteIOSDriver driver) { if (this.driver != null) { throw new WebDriverException("driver already instanciated."); }//from w w w . ja va2s .com this.driver = driver; }
From source file:org.uiautomation.ios.inspector.Model.java
License:Apache License
public InputStream getLastScreenshotInputStream() { try {// w w w . j av a 2 s .co m File f = new File(cache.optString("path")); while (!f.exists()) { log.warning("cannot find " + f + ".Last screenshot cannot be found."); Thread.sleep(250); } InputStream is = new FileInputStream(f); return is; } catch (Exception e) { throw new WebDriverException(e); } }
From source file:org.uiautomation.ios.inspector.Model.java
License:Apache License
public void stop() { RemoteIOSDriver d = getDriver();//w w w . j a v a 2 s. c om if (d == null) { throw new WebDriverException("driver not active."); } else { driver.quit(); driver = null; } }
From source file:org.uiautomation.ios.inspector.views.IDEMainView.java
License:Apache License
@Override public void render(HttpServletResponse response) throws Exception { try {/*from ww w . j a v a2s . com*/ StringBuilder b = new StringBuilder(); b.append("<html>"); b.append("<head>"); //github stuff. //b.append(" <link rel='stylesheet' href='" + getResource("stylesheet.css") + "' type='text/css'/>"); b.append(" <link rel='stylesheet' href='" + getResource("ide.css") + "' type='text/css'/>"); b.append(" <link rel='stylesheet' href='" + getResource("prettify.css") + "' type='text/css'/>"); b.append( "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'></script>"); b.append( " <link rel=\"stylesheet\" href=\"http://code.jquery.com/ui/1.10.1/themes/base/jquery-ui.css\" />"); b.append("<script src=\"http://code.jquery.com/ui/1.10.1/jquery-ui.js\"></script>"); b.append("<script type='text/javascript' src='" + getResource("jquery.jstree.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("jquery.xpath.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("prettify.js") + "'></script>"); DeviceType device = model.getCapabilities().getDevice(); DeviceVariation variation = model.getCapabilities().getDeviceVariation(); b.append("<script type='text/javascript' src='" + getResource("Logger.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("Recorder.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("inspector.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("ide.js") + "'></script>"); b.append("<script type='text/javascript' src='" + getResource("uiactions.js") + "'></script>"); b.append("<script>"); b.append(" $(function() {"); b.append(" $( \"#tabs\" ).tabs();"); b.append("});"); b.append("</script>"); b.append("</head>"); b.append("<body onload=\"prettyPrint()\">"); b.append("<html>"); b.append("<div id='greyout'></div>"); b.append("<div id='simulator'>"); b.append("<div id='mouseOver'></div>"); b.append(" <div id='rotationCenter'>"); b.append("<div id='frame'>"); b.append("<img src='" + getFrame(device, variation) + "' />"); b.append(" <div id='screen'>"); int width = 320; if (device == DeviceType.ipad) { width = 768; } b.append(" <img id='screenshot' src='" + getScreen(device) + "' width='" + width + "px' />"); b.append("</div>"); b.append("</div>"); b.append("</div>"); b.append("</div>"); b.append( "<div id='xpathHelper' >Xpath Expression:</br><input type='text' value='' id='xpathInput' /><div id='xpathLog' > log</div></div>"); b.append("<div id ='detailsparent' >"); b.append("<div id ='details' ></div>"); b.append("</div>"); b.append("<div id ='tree' ></div>"); String d = "iphone"; if (model.getCapabilities().getDevice() == DeviceType.ipad) { d = "ipad"; } b.append("<script >configure('" + d + "','" + variation + "','" + model.getDeviceOrientation() + "');</script>"); b.append("<script >resize();</script>"); b.append("<div id ='topmenu'>"); b.append("<div id=\"picture\"/>"); String icon = getIcon(); if (icon != null) { b.append("<img src=\"" + getIcon() + "\"/>"); } b.append("</div>"); b.append("<ul>"); b.append("<li id=\"capabilities\"><a href=\"#\">See Capabilities</a></li>"); b.append("<li id=\"htmlshow\"><a href=\"#\">See HTML</a></li>"); b.append("</ul>"); b.append("</div>"); b.append(getScriptTabs()); /* * OVERLAY Capabilities */ b.append("<div class=\"overlay\" id=\"overlay\" style=\"display:none;\"></div>"); b.append("<div class=\"box\" id=\"box\">"); b.append("<a class=\"boxclose\" id=\"boxclose\"><p class=\"arrow-left\"></p></a>"); b.append("<h4>Capabilities</h4>"); b.append("<p>"); b.append(displayCapabilities()); b.append("</p>"); b.append("<h4>Supported Languages</h4>"); b.append("<p>"); b.append(getListOfLanguagesInHTML()); b.append("</p>"); b.append("</div>"); /* END OVERLAY CAPABILITIES */ /* * OVERLAY HTML */ b.append("<div class=\"overlayhtml\" id=\"overlayhtml\" style=\"display:none;\"></div>"); b.append("<div class=\"boxhtml\" id=\"boxhtml\">"); b.append("<a class=\"boxclosehtml\" id=\"boxclosehtml\"><p class=\"arrow-right-html\"></p></a>"); b.append("<h4>Web Inspector</h4>"); b.append("<iframe id=\"webinspector\" src=\"ide/session/" + model.getSession() + "/latestWebView\"></iframe> "); b.append("</div>"); /* END OVERLAY HTML */ b.append("</body>"); b.append("</html>"); response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); response.setStatus(200); response.getWriter().print(b.toString()); } catch (Exception e) { throw new WebDriverException(e); } }