mirror of
https://github.com/appium/appium.git
synced 2026-10-27 20:04:24 +08:00
* Do proxying for W3C responses * If a W3C Response is provided by a proxy, map to the correct error * Checks if `value` is an object and `value.error` and maps it based on that (`value.error` is the W3C error code) * Broke off `errorFromCode` into `errorFromMJSONWPStatusCode` and `errorFromW3CJsonCode` * Rename '.error' property to correct W3C property * The error property in the ProtocolError objects should match up with https://www.w3.org/TR/webdriver/#handling-errors under the 'JSON Error Code' column * Added tests for all of these * Make ProxyRequestError work for W3C * Added an arg called `.w3c` that passes in the proxied W3C error * Fixed the `getActualError` function that looks for the .w3c variable and parses error from the code
appium-jsonwp-proxy
Proxy middleware for the Selenium JSON Wire Protocol. Allows
Usage
The proxy is used by instantiating with the details of the Selenium server to which to proxy. The options for the constructor are passed as a hash with the following possible member:
scheme- defaults to 'http'server- defaults to 'localhost'port- defaults to4444base- defaults to '/wd/hub'sessionId- the session id of the session on the remote server
Once the proxy is created, there are two async methods:
command (url, method, body)
Sends a "command" to the proxied server, using the "url", which is the endpoing, with the HTTP method and optional body.
import { JWProxy } from 'appium-base-driver';
let host = 'my.host.com';
let port = 4445;
let proxy = new JWProxy({server: host, port: port});
// get the Selenium server status
let seStatus = await proxy.command('/status', 'GET');
proxyReqRes (req, res)
Proxies a request and response to the proxied server. Used to handle the entire conversation of a request/response cycle.
import { JWProxy } from 'appium-base-driver';
import http from 'http';
let host = 'my.host.com';
let port = 4445;
let proxy = new JWProxy({server: host, port: port});
http.createServer(function (req, res) {
await proxy.proxyReqRes(res, res);
}).listen(9615);