public WebDriverLikeRequest buildRequest(WebDriverLikeCommand command,
RemoteUIAElement element,
Map<String, ?> params,
Map<String, String> extraParamInPath) {
String method = command.method();
Path p = new Path(command).withSession(getSessionId());
// it's ok to have an element id but not mentioning it in the path. That's typically the case
// for alerts.
if (element != null && p.getPath().contains(Path.REFERENCE)) {
p.withReference(element.getReference());
}
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<String, Object>();
builder.put("native", true);
if (params != null) {
builder.putAll(params);
}
for (String key : extraParamInPath.keySet()) {
p.validateAndReplace(":" + key, extraParamInPath.get(key));
}
WebDriverLikeRequest request = new WebDriverLikeRequest(method, p, builder.build());
return request;
}