0

I'm trying to wait for element presence using protractor, typescript.

Here are my code:

import { browser, by, element } from 'protractor';
import { protractor } from 'protractor/built/ptor';

export class LoginPage {

    title = element(by.css('my-page > h3'));

    async openMyPage() {
        await browser.get(browser.baseUrl);
        await browser.wait(protractor.ExpectedConditions.presenceOf(this.title), 5000,
            "Title does not appear during 5 seconds")
    }
}

It fails with error: Failed: Cannot read property 'presenceOf' of undefined.

Could someone help me to understand the reason of this? And how to fix? Thanks

khris
  • 4,809
  • 21
  • 64
  • 94

1 Answers1

0

Try like this:

import { browser, by, element, ElementFinder, protractor } from 'protractor';

export class NameofClass {

public title: ElementFinder;

constructor() {

this.title = element(by.css('my-page > h3'));
}

async openMyPage() {
        await browser.get(browser.baseUrl);
        await browser.wait(protractor.ExpectedConditions.presenceOf(this.title), 5000,
            "Title does not appear during 5 seconds")
    }
}
V.Varshney
  • 151
  • 6