本文整理汇总了Java中org.openqa.selenium.remote.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.openqa.selenium.remote包,在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
JSONObject res = generateStatus();
Set<ServerSideSession> sessions = getServer().getSessions();
Response resp = new Response();
resp.setStatus(0);
resp.setValue(res);
if (sessions.size() == 0) {
resp.setSessionId(null);
} else if (sessions.size() == 1) {
resp.setSessionId(sessions.iterator().next().getSessionId());
} else {
throw new WebDriverException("NI multi sessions per server.");
}
return resp;
}
示例2: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String ref = getRequest().getVariableValue(":reference");
RemoteWebElement element = getWebDriver().createElement(ref);
JsonArray array = getRequest().getPayload().getJsonArray("value");
String value = "";
for (JsonValue jsonValue : array) {
value += JavaxJson.toJavaObject(jsonValue);
}
element.setValueAtoms(value);
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
res.setValue(new JSONObject());
return res;
}
示例3: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
/**
* type - {string} The type of operation to set the timeout for. Valid values are: "script" for
* script timeouts, "implicit" for modifying the implicit wait timeout and "page load" for setting
* a page load timeout.
*/
@Override
public Response handle() throws Exception {
JsonObject payload = getRequest().getPayload();
String type = payload.getString("type", "");
final WebDriverLikeCommand command;
if ("page load".equals(type)) {
command = WebDriverLikeCommand.URL;
} else if ("script".equals(type)) {
command = WebDriverLikeCommand.EXECUTE_SCRIPT;
} else {
throw new UnsupportedCommandException("set timeout for " + payload);
}
long timeout = payload.getJsonNumber("ms").longValue();
getSession().configure(command).set(type, timeout);
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
res.setValue(new JSONObject());
return res;
}
示例4: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String name = getRequest().getVariableValue(":command");
WebDriverLikeCommand command = WebDriverLikeCommand.valueOf(name);
CommandConfiguration conf = getSession().configure(command);
JSONObject res = new JSONObject();
Map<String, Object> m = conf.getAll();
for (String key : m.keySet()) {
res.put(key, m.get(key));
}
Response resp = new Response();
resp.setSessionId(getSession().getSessionId());
resp.setStatus(0);
resp.setValue(res);
return resp;
}
示例5: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
JSONArray res = new JSONArray();
for (ServerSideSession s : getServer().getSessions()) {
JSONObject session = new JSONObject();
session.put("id", s.getSessionId());
session.put("capabilities", new DesiredCapabilities());
res.put(session);
}
Response resp = new Response();
resp.setSessionId("dummy one");
resp.setStatus(0);
resp.setValue(res.toString());
return resp;
}
示例6: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
WebDriverLikeCommand command =
WebDriverLikeCommand.valueOf(getRequest().getVariableValue(":command"));
JSONObject payload = JavaxJson.toOrgJson(getRequest().getPayload());
@SuppressWarnings("unchecked")
Iterator<String> iter = payload.keys();
while (iter.hasNext()) {
String key = iter.next();
Object value = payload.opt(key);
getSession().configure(command).set(key, value);
}
Response resp = new Response();
resp.setSessionId(getSession().getSessionId());
resp.setStatus(0);
resp.setValue(new JSONObject());
return resp;
}
示例7: send
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Nonnull
private Object send(@Nonnull String cmd, @Nonnull Map<String, Object> params) throws IOException {
Map<String, Object> exe = ImmutableMap.of("cmd", cmd, "params", params);
Command xc = new Command(m_wd.getSessionId(), "sendCommandWithResult", exe);
Response response = m_wd.getCommandExecutor().execute(xc);
Object value = response.getValue();
if(response.getStatus() == null || response.getStatus().intValue() != 0) {
//System.out.println("resp: " + response);
throw new MyChromeDriverException("Command '" + cmd + "' failed: " + value);
}
if(null == value)
throw new MyChromeDriverException("Null response value to command '" + cmd + "'");
//System.out.println("resp: " + value);
return value;
}
示例8: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
Response response = new Response();
response.setStatus(ErrorCodes.SUCCESS);
response.setState(ErrorCodes.SUCCESS_STRING);
BuildInfo buildInfo = new BuildInfo();
JsonObject info = new JsonObject();
JsonObject build = new JsonObject();
build.addProperty("version", buildInfo.getReleaseLabel());
build.addProperty("revision", buildInfo.getBuildRevision());
build.addProperty("time", buildInfo.getBuildTime());
info.add("build", build);
JsonObject os = new JsonObject();
os.addProperty("name", System.getProperty("os.name"));
os.addProperty("arch", System.getProperty("os.arch"));
os.addProperty("version", System.getProperty("os.version"));
info.add("os", os);
JsonObject java = new JsonObject();
java.addProperty("version", System.getProperty("java.version"));
info.add("java", java);
response.setValue(info);
return response;
}
示例9: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
// Handle the case where the client does not send any desired capabilities.
sessionId = allSessions.newSession(desiredCapabilities != null
? desiredCapabilities : new DesiredCapabilities());
Map<String, Object> capabilities =
Maps.newHashMap(allSessions.get(sessionId).getCapabilities().asMap());
// Only servers implementing the server-side webdriver-backed selenium need
// to return this particular value
capabilities.put("webdriver.remote.sessionid", sessionId.toString());
if (desiredCapabilities != null) {
LoggingManager.perSessionLogHandler().configureLogging(
(LoggingPreferences)desiredCapabilities.getCapability(CapabilityType.LOGGING_PREFS));
}
LoggingManager.perSessionLogHandler().attachToCurrentThread(sessionId);
Response response = new Response();
response.setSessionId(sessionId.toString());
response.setValue(capabilities);
return response;
}
示例10: execute
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response execute(Command command) throws IOException {
Response response;
if (DriverCommand.QUIT.equals(command.getName())) {
response = grid.execute(command);
} else {
response = node.execute(command);
}
return response;
}
示例11: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String ref = getRequest().getVariableValue(":reference");
RemoteWebElement element = getWebDriver().createElement(ref);
String text = element.getText();
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
res.setValue(text);
return res;
}
示例12: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String url = getRequest().getPayload().getString("url");
getWebDriver().get(url);
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
res.setValue(new JSONObject());
return res;
}
示例13: createResponse
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
final Response createResponse(Object value) {
Response r = new Response();
r.setSessionId(getSession().getSessionId());
r.setStatus(0);
r.setValue(value);
return r;
}
示例14: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String url = getWebDriver().getCurrentUrl();
List<Cookie> cookies = getWebDriver().getCookies();
for (Cookie c : cookies) {
getWebDriver().deleteCookie(c.getName(), url);
}
Response res = new Response();
res.setSessionId(getSession().getSessionId());
res.setStatus(0);
res.setValue(new JSONObject());
return res;
}
示例15: handle
import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
String ref = getRequest().getVariableValue(":reference");
RemoteWebElement element = getWebDriver().createElement(ref);
element.clear();
Response resp = new Response();
resp.setSessionId(getSession().getSessionId());
resp.setStatus(0);
resp.setValue(new JSONObject());
return resp;
}