attachSession.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. /*
  4. * This is an implementation of the Attach Session Driver Provider.
  5. * It is responsible for setting up the account object, tearing
  6. * it down, and setting up the driver correctly.
  7. */
  8. const q = require("q");
  9. const selenium_webdriver_1 = require("selenium-webdriver");
  10. const logger_1 = require("../logger");
  11. const driverProvider_1 = require("./driverProvider");
  12. const http = require('selenium-webdriver/http');
  13. let logger = new logger_1.Logger('attachSession');
  14. class AttachSession extends driverProvider_1.DriverProvider {
  15. constructor(config) {
  16. super(config);
  17. }
  18. /**
  19. * Configure and launch (if applicable) the object's environment.
  20. * @return {q.promise} A promise which will resolve when the environment is
  21. * ready to test.
  22. */
  23. setupDriverEnv() {
  24. logger.info('Using the selenium server at ' + this.config_.seleniumAddress);
  25. logger.info('Using session id - ' + this.config_.seleniumSessionId);
  26. return q(undefined);
  27. }
  28. /**
  29. * Getting a new driver by attaching an existing session.
  30. *
  31. * @public
  32. * @return {WebDriver} webdriver instance
  33. */
  34. getNewDriver() {
  35. const httpClient = new http.HttpClient(this.config_.seleniumAddress);
  36. const executor = new http.Executor(httpClient);
  37. const newDriver = selenium_webdriver_1.WebDriver.attachToSession(executor, this.config_.seleniumSessionId);
  38. this.drivers_.push(newDriver);
  39. return newDriver;
  40. }
  41. /**
  42. * Maintains the existing session and does not quit the driver.
  43. *
  44. * @public
  45. */
  46. quitDriver() {
  47. return selenium_webdriver_1.promise.when(undefined);
  48. }
  49. }
  50. exports.AttachSession = AttachSession;
  51. //# sourceMappingURL=attachSession.js.map