webdriver_proxy.d.ts 1.1 KB

123456789101112131415161718192021222324
  1. /// <reference types="node" />
  2. import * as http from 'http';
  3. import { WebDriverCommand } from './webdriver_commands';
  4. /**
  5. * A proxy that understands WebDriver commands. Users can add barriers (similar to middleware in
  6. * express) that will be called before forwarding the request to WebDriver. The proxy will wait for
  7. * each barrier to finish, calling them in the order in which they were added.
  8. */
  9. export declare class WebDriverProxy {
  10. barriers: WebDriverBarrier[];
  11. seleniumAddress: string;
  12. constructor(seleniumAddress: string);
  13. addBarrier(barrier: WebDriverBarrier): void;
  14. handleRequest(originalRequest: http.IncomingMessage, response: http.ServerResponse): Promise<void>;
  15. }
  16. /**
  17. * When the proxy receives a WebDriver command, it will call onCommand() for each of it's barriers.
  18. * Barriers may return a promise for the proxy to wait for before proceeding. If the promise is
  19. * rejected, the proxy will reply with an error code and the result of the promise and the command
  20. * will not be forwarded to Selenium.
  21. */
  22. export interface WebDriverBarrier {
  23. onCommand(command: WebDriverCommand): Promise<void>;
  24. }