• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.openqa.selenium.remote.Response的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Response类属于org.openqa.selenium.remote包,在下文中一共展示了Response类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:19,代码来源:ServerStatusHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:19,代码来源:SetValueHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:28,代码来源:SetTimeoutHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:20,代码来源:GetConfigurationHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:17,代码来源:GetSessionsHandler.java


示例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;

}
 
开发者ID:google,项目名称:devtools-driver,代码行数:22,代码来源:SetConfigurationHandler.java


示例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;
}
 
开发者ID:fjalvingh,项目名称:domui,代码行数:17,代码来源:ChromeExtender.java


示例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;
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:27,代码来源:Status.java


示例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;
}
 
开发者ID:alexkogon,项目名称:grid-refactor-remote-server,代码行数:25,代码来源:NewSession.java


示例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;
}
 
开发者ID:RationaleEmotions,项目名称:talk2grid,代码行数:11,代码来源:CustomCommandExecutor.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:GetTextHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:11,代码来源:GetHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:8,代码来源:CommandHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:15,代码来源:DeleteAllCookiesHandler.java


示例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;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:ClearHandler.java


示例16: handle

import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
  String attributeName = getRequest().getVariableValue(":name");
  String ref = getRequest().getVariableValue(":reference");
  RemoteWebElement element = getWebDriver().createElement(ref);
  Object value = element.getAttribute(attributeName);
  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(value);
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:13,代码来源:GetAttributeHandler.java


示例17: handle

import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
  String ref = getRequest().getVariableValue(":reference");
  RemoteWebElement element = getWebDriver().createElement(ref);
  Dimension size = element.getSize();
  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(size);
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:GetElementSizeHandler.java


示例18: handle

import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
  String ref = getRequest().getVariableValue(":reference");
  RemoteWebElement element = getWebDriver().createElement(ref);
  boolean isSelected = element.isSelected();
  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(isSelected);
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:IsSelectedHandler.java


示例19: handle

import org.openqa.selenium.remote.Response; //导入依赖的package包/类
@Override
public Response handle() throws Exception {
  String value = getWebDriver().getCurrentPageId().asString();

  Response resp = new Response();
  resp.setSessionId(getSession().getSessionId());
  resp.setStatus(0);
  resp.setValue(value);
  return resp;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:11,代码来源:GetCurrentContextHandler.java


示例20: 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.submit();
  Response res = new Response();
  res.setSessionId(getSession().getSessionId());
  res.setStatus(0);
  res.setValue(new JSONObject());
  return res;
}
 
开发者ID:google,项目名称:devtools-driver,代码行数:12,代码来源:SubmitHandler.java



注:本文中的org.openqa.selenium.remote.Response类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FillPatternType类代码示例发布时间:2022-05-21
下一篇:
Java DiskFileItemFactory类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap