public Object executeScript(String script, Object... args) { ChromeResponse response; response = execute("execute", script, args); if (response.getStatusCode() == -1) { return new ChromeWebElement(this, response.getValue().toString()); } else { return response.getValue(); } }
@Override public String toString() { return String.format("(%d: %s)", statusCode, getValue()); } }
return new ChromeResponse(0, null); return new ChromeResponse(0, null); return new ChromeResponse(-1, ((ChromeWebElement)parsedValue).getElementId()); } else { return new ChromeResponse(0, parsedValue);
WebElement getElementFrom(ChromeResponse response) { Object result = response.getValue(); List<?> elements = (List<?>)result; return new ChromeWebElement(this, (String)elements.get(0)); }
public Set<Cookie> getCookies() { List<?> result = (List<?>)execute("getCookies").getValue(); Set<Cookie> cookies = new HashSet<Cookie>(); for (Object cookie : result) { cookies.add((Cookie)cookie); } return cookies; }
public String getValueOfCssProperty(String propertyName) { return parent.execute("getElementValueOfCssProperty", this, propertyName) .getValue().toString(); }
public boolean toggle() { return Boolean.parseBoolean(execute("toggleElement", this) .getValue().toString()); }
public boolean isDisplayed() { ChromeResponse r = execute("isElementDisplayed", this); return (Boolean)r.getValue(); }
public boolean isSelected() { return Boolean.parseBoolean(execute("isElementSelected", this) .getValue().toString()); }
public Set<String> getWindowHandles() { List<?> windowHandles = (List<?>)execute("getWindowHandles").getValue(); Set<String> setOfHandles = new HashSet<String>(); for (Object windowHandle : windowHandles) { setOfHandles.add((String)windowHandle); } return setOfHandles; }
List<WebElement> getElementsFrom(ChromeResponse response) { Object result = response.getValue(); List<WebElement> elements = new ArrayList<WebElement>(); for (Object element : (List<?>)result) { elements.add(new ChromeWebElement(this, (String)element)); } return elements; }
public Cookie getCookieNamed(String name) { return (Cookie)execute("getCookieNamed", name).getValue(); }
public String getAttribute(String name) { Object value = execute("getElementAttribute", this, name).getValue(); return (value == null) ? null : value.toString(); }
public String getCurrentUrl() { return execute("getCurrentUrl").getValue().toString(); }
public String getWindowHandle() { return execute("getWindowHandle").getValue().toString(); }
public String getPageSource() { return execute("getPageSource").getValue().toString(); }
public Dimension getSize() { return (Dimension)parent.execute("getElementSize", this).getValue(); }
public String getTagName() { return execute("getElementTagName", this).getValue().toString(); }
public String getValue() { return execute("getElementValue", this).getValue().toString(); }