visual-studio-2013 - 类型 'typeof protractor' 上不存在“ExpectedConditions”

标签 visual-studio-2013 typescript protractor

我正在 Visual Studio 2013 中使用 TypeScript 编写 Protractor 测试,但收到错误:

Property 'ExpectedConditions' does not exist on type 'typeof protractor'.

我读过类似的问题( here ),但它对我的情况没有帮助。

这是我的页面对象代码:

class SheetObjects {
    EC = protractor.ExpectedConditions;
    showList = element(by.buttonText('Show as List'));
    copyItem = element.all(by.binding('item.name')).get(2);
    copyDiv = element(by.className('md-inline-list-icon-label'));
    alertItem = element(by.binding('alert'));
    alertDiv = element(by.css('[ng-if="alert"]'))

    NavigateToPage() {
        browser.get('https://material.angularjs.org/latest/#/demo/material.components.bottomSheet');
    }

    WaitForElements(element: any) {
        browser.wait(() => element.isPresent(), 5000);
    }

    ClickOn(element: any) {
        element.click();
    }
}
module.exports = new SheetObjects();

这是我的packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="angular-protractor.TypeScript.DefinitelyTyped" version="2.1.1" targetFramework="net45" />
  <package id="jasmine.TypeScript.DefinitelyTyped" version="1.3.4" targetFramework="net45" />
  <package id="node.TypeScript.DefinitelyTyped" version="1.5.6" targetFramework="net45" />
  <package id="Protractor" version="0.5.0" targetFramework="net45" />
  <package id="Selenium.WebDriver" version="2.45.0" targetFramework="net45" />
  <package id="selenium-webdriver.TypeScript.DefinitelyTyped" version="0.3.7" targetFramework="net45" />
</packages>

我认为 ExpectedConditions 将包含在其中一个包中,但到目前为止还没有解决它。

最佳答案

I figured ExpectedConditions would be included in one of those packages but so far nothing has fixed it.

它不是https://github.com/borisyankov/DefinitelyTyped/search?utf8=%E2%9C%93&q=ExpectedConditions这意味着该定义对于当前实际 Protractor 代码来说有点过时:http://angular.github.io/protractor/#/api?view=ExpectedConditions

热修复

以非类型化方式使用它:

EC = (<any>protractor).ExpectedConditions;

关于visual-studio-2013 - 类型 'typeof protractor' 上不存在“ExpectedConditions”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31172265/

相关文章:

c++ - DirectX 11 : Shader not creating world view matrix

typescript :使用将对象转换为其他类型。如何?还有 instanceof 或 typeof?

typescript - 在baseUrl之外导入文件时汇总+ Typescript错误

javascript - Protractor 关闭当前选项卡

visual-studio-2013 - MS Visual Studio 2013 中没有 <optional> - 怎么办?

powershell - NuGet install.ps1 脚本中的 $package 和 $project 参数包含什么?

c++ - "Object reference not set to an instance of an object"弹出 Visual Studio 桌面

javascript - vscode 在打开的文件上自动折叠

javascript - 问:全部不工作

javascript - 动态时如何在 Protractor 中定位 'datepicker'实例