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

主宰稳场 提交于 2020-01-04 15:17:09

问题


I'm writing a protractor test in TypeScript in Visual Studio 2013 and I'm getting the error:

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

I read a similar question (here) but it did not help my situation.

This is my page objects code:

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();

This is my 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>

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


回答1:


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

its not https://github.com/borisyankov/DefinitelyTyped/search?utf8=%E2%9C%93&q=ExpectedConditions This implies that the definition is a bit out of date with the current actual protractor code : http://angular.github.io/protractor/#/api?view=ExpectedConditions

Hot fix

Just use it in an untyped manner:

EC = (<any>protractor).ExpectedConditions;


来源:https://stackoverflow.com/questions/31172265/expectedconditions-does-not-exist-on-type-typeof-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!