List of usage examples for org.openqa.selenium.remote DriverCommand SCREENSHOT
String SCREENSHOT
To view the source code for org.openqa.selenium.remote DriverCommand SCREENSHOT.
Click Source Link
From source file:com.elastica.driver.ScreenShotRemoteWebDriver.java
License:Apache License
public <X> X getScreenshotAs(final OutputType<X> target) throws WebDriverException { if ((Boolean) getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT)) { String output = execute(DriverCommand.SCREENSHOT).getValue().toString(); return target.convertFromBase64Png(output); }// w w w . j av a 2s.c o m return null; }
From source file:com.google.iphone.testing.nativedriver.client.IosNativeDriver.java
License:Apache License
public File takeScreenshot() { String png = (String) execute(DriverCommand.SCREENSHOT).getValue(); return OutputType.FILE.convertFromBase64Png(png); }
From source file:com.jaliansystems.customiSE.driver.CustomiSEDriver.java
License:Apache License
public <X> X getScreenshotAs(OutputType<X> target) { // Get the screenshot as base64. String base64 = execute(DriverCommand.SCREENSHOT).getValue().toString(); // ... and convert it. return target.convertFromBase64Png(base64); }
From source file:com.lohika.alp.selenium.RemoteWebDriverTakeScreenshotFix.java
License:Open Source License
@Override public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException { // Get the screenshot as base64. String base64 = execute(DriverCommand.SCREENSHOT).getValue().toString(); // ... and convert it. return target.convertFromBase64Png(base64); }
From source file:com.qmetry.qaf.automation.ui.webdriver.QAFExtendedWebDriver.java
License:Open Source License
@Override public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException { Object takeScreenshot = getCapabilities().getCapability(CapabilityType.TAKES_SCREENSHOT); if (null == takeScreenshot || (Boolean) takeScreenshot) { String base64Str = execute(DriverCommand.SCREENSHOT).getValue().toString(); return target.convertFromBase64Png(base64Str); }/*from ww w. j a v a 2 s . c om*/ return null; }
From source file:com.smash.revolance.ui.materials.mock.webdriver.browser.MockedBrowserController.java
License:Open Source License
@Override public synchronized void notify(JSonWireEvent event) { String name = (String) event.getProp("command.name"); String path = (String) event.getProp("command.path"); String elementId = (String) event.getProp("command.elementId"); String htmlAttribute = (String) event.getProp("command.elementHtmlAttribute"); String cssAttribute = (String) event.getProp("command.elementCssAttribute"); System.out.println("Receiving command: " + name + " with path: " + path); Map<String, Object> commandPayload = (Map<String, Object>) event.getProp("command.payload"); // Just the value part in the payload Map<String, Object> resultPayload = new HashMap<String, Object>(); if (isCommand(event, DriverCommand.NEW_SESSION)) { browser = new MockedBrowser(); resultPayload.put("browserName", this.getClass().getSimpleName()); resultPayload.put("browserPlatform", OS.isFamilyUnix() ? "LINUX" : "WINDOWS"); resultPayload.put("browserVersion", "0.0.1-SNAPSHOT"); }/* w w w . j a v a2 s . co m*/ if (isCommand(event, DriverCommand.SET_WINDOW_SIZE)) { browser.setSize((Integer) commandPayload.get("width"), (Integer) commandPayload.get("height")); } if (isCommand(event, DriverCommand.GET_WINDOW_SIZE)) { Dimension dim = browser.getDimension(); resultPayload.put("width", dim.getWidth()); resultPayload.put("height", dim.getHeight()); } if (isCommand(event, DriverCommand.SET_WINDOW_POSITION)) { browser.setLocation((Integer) commandPayload.get("x"), (Integer) commandPayload.get("y")); } if (isCommand(event, DriverCommand.GET_WINDOW_POSITION)) { Point location = browser.getLocation(); resultPayload.put("x", location.getX()); resultPayload.put("y", location.getY()); } if (isCommand(event, DriverCommand.GET_CURRENT_URL)) { resultPayload.put("url", browser.getUrl()); } if (isCommand(event, DriverCommand.GET)) { try { browser.goToUrl((String) commandPayload.get("url")); } catch (Exception e) { System.err.println(e); } } if (isCommand(event, DriverCommand.EXECUTE_SCRIPT)) { resultPayload.put("value", browser.executeJavaScript((String) commandPayload.get("script"), (Object[]) commandPayload.get("args"))); } if (isCommand(event, DriverCommand.GET_ALERT_TEXT)) { resultPayload.put("alertStatusCode", ErrorCodes.NO_ALERT_PRESENT); resultPayload.put("alertMessage", "No alert is present"); } if (isCommand(event, DriverCommand.GET_TITLE)) { resultPayload.put("title", browser.getTitle()); } if (isCommand(event, DriverCommand.SCREENSHOT)) { resultPayload.put("screenshot", browser.takeScreenshot()); } if (isCommand(event, DriverCommand.FIND_ELEMENTS)) { List<String> elements = browser.findElements((String) commandPayload.get("value")); resultPayload.put("elementList", buildElementList(elements)); } if (isCommand(event, DriverCommand.GET_ELEMENT_LOCATION)) { Point location = browser.getElementLocation(elementId); resultPayload.put("elementX", String.valueOf(location.getX())); resultPayload.put("elementY", String.valueOf(location.getY())); } if (isCommand(event, DriverCommand.GET_ELEMENT_SIZE)) { Dimension dim = browser.getElementSize(elementId); resultPayload.put("elementW", String.valueOf(dim.getWidth())); resultPayload.put("elementH", String.valueOf(dim.getHeight())); } if (isCommand(event, DriverCommand.GET_ELEMENT_TAG_NAME)) { resultPayload.put("elementTagName", browser.getElementTag(elementId)); } if (isCommand(event, DriverCommand.GET_ELEMENT_TEXT)) { resultPayload.put("elementText", browser.getElementText(elementId)); } if (isCommand(event, DriverCommand.GET_ELEMENT_ATTRIBUTE)) { resultPayload.put("elementHtmlAttributeValue", browser.getElementHtmlAttribute(elementId, htmlAttribute)); } if (isCommand(event, DriverCommand.IS_ELEMENT_DISPLAYED)) { resultPayload.put("isElementDisplayed", browser.isElementDisplayed(elementId)); } if (isCommand(event, DriverCommand.GET_ELEMENT_VALUE_OF_CSS_PROPERTY)) { resultPayload.put("elementCssAttributeValue", browser.getElementCssAttribute(elementId, cssAttribute)); } event.setProp("command.value", resultPayload); notifyAll(); }
From source file:com.smash.revolance.ui.materials.mock.webdriver.handler.JSonWireController.java
License:Open Source License
@GET @Path("/session/{sessionId}/screenshot") @Consumes(MediaType.APPLICATION_JSON)//from www .j a v a2s .c om @Produces(MediaType.APPLICATION_JSON) public Response takeScreenshot(@PathParam("sessionId") String sessionId) { Command cmd = new Command(sessionId, DriverCommand.SCREENSHOT, "GET"); CommandResult cmdResult = new CommandExecutor(cmd, getPath()).execute(); return new CommandResponse(cmdResult).buildResponse(); }
From source file:org.openqa.selendroid.SelendroidDriver.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . j a va 2s . co m*/ */ @Override public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException { String base64 = execute(DriverCommand.SCREENSHOT).getValue().toString(); return target.convertFromBase64Png(base64); }
From source file:phantomjs.PhantomJSDriver.java
License:Apache License
/** * Take screenshot of the current window. * * @param target The target type/format of the Screenshot * @return Screenshot of current window, in the requested format * @throws WebDriverException/*from w w w . ja v a 2 s .com*/ * @see TakesScreenshot#getScreenshotAs(org.openqa.selenium.OutputType) */ @Override public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException { // Get the screenshot as base64 and convert it to the requested type (i.e. OutputType<T>) String base64 = (String) execute(DriverCommand.SCREENSHOT).getValue(); return target.convertFromBase64Png(base64); }