如何使用Typescript在Atom中集成Protractor测试用例? [英] How to integrate Protractor test cases in Atom using Typescript?

查看:157
本文介绍了如何使用Typescript在Atom中集成Protractor测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了原型的typescript来编写Protractor脚本用于自动化。

I have installed typescript for atom for writing Protractor Scripts For automation.

我的代码是用Jasmine Framework编写的,因为量角器很好地支持它。

My code is written in Jasmine Framework as protractor supports it nicely.

我在这个结构中写道。

 describe('Sign in',function(){
     it ('Verify Modules Present', function(){
     loginPage.enterUsernameAndPasswordWithSignIn('a','b');
     browser.sleep(3000);
     var module = element(by.xpath("//*[@ng-reflect-router-link='My']"));
     browser.wait(protractor.ExpectedConditions.elementToBeClickable(module),
                                  8000).thenCatch(function () {
              assert.fail(' element is not click able');
      });
    var expectedModuleName = ["My", "X","Y", "Z" ];
    var testArray = ["My", "X","Y", "Z" ];;
    logger.log('info','Checking All modules');
    for (var i = 0; i < testArray.length;i++) {
      var moduleName = text.verifyText("//*[@ng-reflect-router-link='"+ testArray[i] + "']");
      expect(moduleName).toBe(expectedModuleName[i]);
    }
  logger.log('info','Checked All modules');
  });
});

我收到以下错误。

我的理解是:Typescript无法找到Jasmine库。
怎么办?

My understanding is : The Typescript is not able to find Jasmine libraries. How to do so?

我经历过: https://angular.io/docs/ts/latest/testing/jasmine-testing-101.html

但不能发现很多。我也安装了打字。但我不知道如何使用它。

But couldn't find much. I installed typings too. But I don't know how to use it.

我如何为Protractor配置Jasmine Framework into atom以便解决这个错误?

How can i configure Jasmine Framework into atom for Protractor so that this errors may resolve?

如果不是这样的话,哪个编辑器可以这样做以及如何使用?

If not so, Which editor can be useful to do so and how?

请指导我..

推荐答案

您必须安装 jasmine node typings,以便打字稿识别它们。现在甚至有更好的方法,不需要typings文件夹和typings.json。我们有相同的 @types 依赖项。

You have to install jasmine and node typings so that typescript recognizes them. Now there is even a better approach, there is no need of typings folder and typings.json. we have @types dependencies for the same.

所以你可以按照以下步骤来做到这一点 -

so you can do that by following steps-

转到项目文件夹并安装依赖项 -

go to your project folder and install the dependencies -

 npm install --save-dev @types/jasmine //this would install jasmine typings as a dev dependency in your package.json
 npm install --save-dev @types/node   //this would install node typings as a dev dependency in your package.json

安装后尝试使用 tsc tsc -w 观看模式,现在您不应该看到那些TS语法错误!

once you have installed try compiling it with tsc or tsc -w watch mode, now you shouldn't see those TS syntax errors!

你必须从量角器/全局导入浏览器才能使用它的方法,如下所示 -

And you have to import browser from protractor/globals to use its methods, like this-

import {browser} from 'protractor/globals';

有关详细信息,请查看我的代表,了解带有打字稿的量角器它使用黄瓜以及你可以查看官方量角器 - 打字稿示例

For more details you can check out my rep for initial setup of protractor with typescript it uses cucumber as well as you can check out the official protractor-typescript example

这篇关于如何使用Typescript在Atom中集成Protractor测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆