• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript selenium-webdriver.WebDriver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中selenium-webdriver.WebDriver的典型用法代码示例。如果您正苦于以下问题:TypeScript WebDriver类的具体用法?TypeScript WebDriver怎么用?TypeScript WebDriver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WebDriver类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: quitDriver

  /**
   * Quit a driver.
   *
   * @public
   * @param webdriver instance
   */
  quitDriver(driver: WebDriver): q.Promise<WebDriver> {
    let driverIndex = this.drivers_.indexOf(driver);
    if (driverIndex >= 0) {
      this.drivers_.splice(driverIndex, 1);
    }

    let deferred = q.defer<WebDriver>();
    if (driver.getSession() === undefined) {
      deferred.resolve();
    } else {
      driver.getSession()
          .then((session_: Session) => {
            if (session_) {
              driver.quit().then(function() {
                deferred.resolve();
              });
            } else {
              deferred.resolve();
            }
          })
          .catch((err: Error) => {
            deferred.resolve();
          });
    }
    return deferred.promise;
  }
开发者ID:MexicanAce,项目名称:protractor,代码行数:32,代码来源:driverProvider.ts


示例2: getNewDriver

 /**
  * Getting a new driver by attaching an existing session.
  *
  * @public
  * @return {WebDriver} webdriver instance
  */
 getNewDriver(): WebDriver {
   const httpClient = new http.HttpClient(this.config_.seleniumAddress);
   const executor = new http.Executor(httpClient);
   const newDriver = WebDriver.attachToSession(executor, this.config_.seleniumSessionId);
   this.drivers_.push(newDriver);
   return newDriver;
 }
开发者ID:DylanLacey,项目名称:protractor,代码行数:13,代码来源:attachSession.ts


示例3: BrowserError

    let mappedDrivers = this.drivers_.map(async (driver: WebDriver) => {
      let session = await driver.getSession();

      // Fetching BrowserStack session details.
      this.browserstackClient.getSession(
          session.getId(), function(error: Error, automate_session: any) {
            if (error) {
              logger.info(
                  'BrowserStack results available at ' +
                  'https://www.browserstack.com/automate');
            } else {
              if (automate_session && automate_session.browser_url) {
                logger.info('BrowserStack results available at ' + automate_session.browser_url);
              } else {
                logger.info(
                    'BrowserStack results available at ' +
                    'https://www.browserstack.com/automate');
              }
            }
          });

      let jobStatus = update.passed ? 'completed' : 'error';
      let statusObj = {status: jobStatus};

      // Updating status of BrowserStack session.
      this.browserstackClient.updateSession(
          session.getId(), statusObj, function(error: Error, automate_session: any) {
            if (error) {
              throw new BrowserError(
                  logger, 'Error updating BrowserStack pass/fail status: ' + util.inspect(error));
            } else {
              logger.info(automate_session);
            }
          });
    });
开发者ID:angular,项目名称:protractor,代码行数:35,代码来源:browserStack.ts


示例4: getNewDriver

 /**
  * Getting a new driver by attaching an existing session.
  *
  * @public
  * @return {WebDriver} webdriver instance
  */
 getNewDriver(): webdriver.WebDriver {
   var executor = executors.createExecutor(this.config_.seleniumAddress);
   var newDriver = webdriver.WebDriver.attachToSession(
       executor, this.config_.seleniumSessionId);
   this.drivers_.push(newDriver);
   return newDriver;
 }
开发者ID:AleNoemi,项目名称:protractor,代码行数:13,代码来源:attachSession.ts


示例5: describe

describe('Google Search', () => {
    let driver: WebDriver;

    before(() => {
        driver = new Builder().forBrowser('firefox').build();
    });

    beforeEach(() => { });

    after(() => {
        driver.quit();
    });

    afterEach(() => { });

    it('should append query to title', () => {
        const flow = controlFlow();
        flow.execute(() => {
            driver.get('http://www.google.com/ncr');
            driver.findElement(By.name('q')).sendKeys('webdriver');
            driver.findElement(By.name('btnG')).click();
            driver.wait(until.titleIs('webdriver - Google Search'), 1000);
        });
    });
});
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:25,代码来源:testing.ts


示例6: getNewDriver

 /**
  * Getting a new driver by attaching an existing session.
  *
  * @public
  * @return {WebDriver} webdriver instance
  */
 async getNewDriver(): Promise<WebDriver> {
   const httpClient = new http.HttpClient(this.config_.seleniumAddress);
   const executor = new http.Executor(httpClient);
   const newDriver =
       await WebDriver.attachToSession(executor, this.config_.seleniumSessionId, null);
   this.drivers_.push(newDriver);
   return newDriver;
 }
开发者ID:jan-molak,项目名称:protractor,代码行数:14,代码来源:attachSession.ts


示例7: Buffer

    let deferredArray = this.drivers_.map((driver: WebDriver) => {
      let deferred = q.defer();
      driver.getSession().then((session: Session) => {
        let headers: Object = {
          'Content-Type': 'application/json',
          'Authorization': 'Basic ' +
              new Buffer(this.config_.browserstackUser + ':' + this.config_.browserstackKey)
                  .toString('base64')
        };
        let options = {
          hostname: 'www.browserstack.com',
          port: 443,
          path: '/automate/sessions/' + session.getId() + '.json',
          method: 'GET',
          headers: headers
        };

        let req = https.request(options, (res) => {
          res.on('data', (data: Buffer) => {
            let info = JSON.parse(data.toString());
            if (info && info.automation_session && info.automation_session.browser_url) {
              logger.info(
                  'BrowserStack results available at ' + info.automation_session.browser_url);
            } else {
              logger.info(
                  'BrowserStack results available at ' +
                  'https://www.browserstack.com/automate');
            }
          });
        });
        req.end();
        req.on('error', (e: Error) => {
          logger.info(
              'BrowserStack results available at ' +
              'https://www.browserstack.com/automate');
        });
        let jobStatus = update.passed ? 'completed' : 'error';
        options.method = 'PUT';
        let update_req = https.request(options, (res) => {
          let responseStr = '';
          res.on('data', (data: Buffer) => {
            responseStr += data.toString();
          });
          res.on('end', () => {
            logger.info(responseStr);
            deferred.resolve();
          });
          res.on('error', (e: Error) => {
            throw new BrowserError(
                logger, 'Error updating BrowserStack pass/fail status: ' + util.inspect(e));
          });
        });
        update_req.write('{"status":"' + jobStatus + '"}');
        update_req.end();
      });
      return deferred.promise;
    });
开发者ID:MexicanAce,项目名称:protractor,代码行数:57,代码来源:browserStack.ts


示例8: verifyNoBrowserErrors

export async function verifyNoBrowserErrors() {
  const browserLog = await browser.manage().logs().get('browser');
  const collectedErrors: any[] = [];

  browserLog.forEach(logEntry => {
    const msg = logEntry.message;

    // Since we currently use the `ts_devserver` from the Bazel TypeScript rules, which does
    // fallback to the "index.html" file for HTML5 pushState routing but does always serve the
    // expected fallback with a 404 status code, the browser will print a message about the 404,
    // while the page loaded properly. Ideally the "ts_devserver" would allow us to opt-in for
    // just returning a 200 status code, but the devserver is intended to be kept manually, so
    // we manually filter this error before ensuring there are no console errors.
    // TODO: This is a current limitation of using the "ts_devserver" with Angular routing.
    // Tracked with: TOOL-629
    if (msg.includes(
            `Failed to load resource: the server responded with a status of 404 (Not Found)`)) {
      return;
    }

    console.log('>> ' + msg, logEntry);

    if (logEntry.level.value >= logging.Level.INFO.value) {
      collectedErrors.push(msg);
    }
  });

  expect(collectedErrors).toEqual([]);
}
开发者ID:Cammisuli,项目名称:angular,代码行数:29,代码来源:index.ts


示例9: RangeError

 /**
  * Executes a command which was defined by defineCommand()
  *
  * @param {string} name The command name.
  * @param {*[]} params The parameters to the command
  * @return {webdriver.promise.Promise<*>} A promise that will be resolved with
  *     the command result
  */
 execCommand<T>(name: string, method: string, params: any[]): wdpromise.Promise<T> {
   var paramNames = this.params_[method + ':' + name];
   if (paramNames === undefined) {
     throw new RangeError('The command "' + name + '" has not yet been defined');
   }
   if (paramNames.length !== params.length) {
     throw new RangeError(
         'The command "' + name + '" expected ' + paramNames.length + ' parameters, got ' +
         params.length);
   }
   var command = new Command(name);
   for (var i = 0; i < params.length; i++) {
     if (params[i] !== undefined) {
       command.setParameter(paramNames[i], params[i]);
     }
   }
   return this.driver_.schedule(
       command,
       'Custom Command: ' + name + '(' +
           params
               .map((x: any) => {
                 if ((typeof x == 'number') || (typeof x == 'boolean') ||
                     (typeof x == 'function')) {
                   return x.toString();
                 } else if (x == null) {
                   return '' + x;
                 } else {
                   return JSON.stringify(x);
                 }
               })
               .join(', ') +
           ')');
 }
开发者ID:angular,项目名称:webdriver-js-extender,代码行数:41,代码来源:extender.ts


示例10: checkContent

  @AsyncTest("everyone gets a nice welcome")
  public async checkContent() {
    // get the wiki body
    const title = await this._driver.findElement(By.id("wiki-body")).getText();

    // check it contains what we'd expect
    Expect(title).toContain("Welcome to the alsatian wiki!");
  }
开发者ID:alsatian-test,项目名称:alsatian,代码行数:8,代码来源:alsatian-wiki.spec.ts



注:本文中的selenium-webdriver.WebDriver类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript selenium-webdriver.WebElement类代码示例发布时间:2022-05-25
下一篇:
TypeScript selenium-webdriver.Session类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap