webdriver_commands.d.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /// <reference types="node" />
  2. /**
  3. * Utilities for parsing WebDriver commands from HTTP Requests.
  4. */
  5. import * as events from 'events';
  6. export declare type HttpMethod = 'GET' | 'POST' | 'DELETE';
  7. export declare type paramKey = 'sessionId' | 'elementId' | 'name' | 'propertyName';
  8. export declare enum CommandName {
  9. NewSession = 0,
  10. DeleteSession = 1,
  11. Status = 2,
  12. GetTimeouts = 3,
  13. SetTimeouts = 4,
  14. Go = 5,
  15. GetCurrentURL = 6,
  16. Back = 7,
  17. Forward = 8,
  18. Refresh = 9,
  19. GetTitle = 10,
  20. FindElement = 11,
  21. FindElements = 12,
  22. FindElementFromElement = 13,
  23. FindElementsFromElement = 14,
  24. IsElementSelected = 15,
  25. GetElementAttribute = 16,
  26. GetElementProperty = 17,
  27. GetElementCSSValue = 18,
  28. GetElementText = 19,
  29. GetElementTagName = 20,
  30. GetElementRect = 21,
  31. IsElementEnabled = 22,
  32. ElementClick = 23,
  33. ElementClear = 24,
  34. ElementSendKeys = 25,
  35. WireMoveTo = 26,
  36. WireButtonDown = 27,
  37. WireButtonUp = 28,
  38. GetAlertText = 29,
  39. AcceptAlert = 30,
  40. DismissAlert = 31,
  41. UNKNOWN = 32,
  42. }
  43. /**
  44. * An instance of a WebDriver command, containing the params and data for that request.
  45. *
  46. * @param commandName The enum identifying the command.
  47. * @param params Parameters for the command taken from the request's url.
  48. * @param data Optional data included with the command, taken from the body of the request.
  49. */
  50. export declare class WebDriverCommand extends events.EventEmitter {
  51. commandName: CommandName;
  52. readonly url: string;
  53. readonly method: HttpMethod;
  54. private params;
  55. data: any;
  56. responseStatus: number;
  57. responseData: any;
  58. readonly sessionId: string;
  59. constructor(commandName: CommandName, url: string, method: HttpMethod, params?: any);
  60. getParam(key: paramKey): string;
  61. handleData(data?: any): void;
  62. handleResponse(statusCode: number, data?: any): void;
  63. }
  64. /**
  65. * Returns a new WebdriverCommand object for the resource at the given URL.
  66. */
  67. export declare function parseWebDriverCommand(url: any, method: any): WebDriverCommand;