I tried to wait for an input loading. So, I used expectedconditions.elementToBeClickable like this:
it('test expected conditions', async function () {
await browser.waitForAngularEnabled(false);
await browser.driver.get('https://www.baidu.com');
var EC = protractor.ExpectedConditions;
await browser.wait(EC.elementToBeClickable(element(by.css('kw'))), 5000);
element(by.css('#kw')).sendKeys('protractor')
element(by.css('#su')).click()
browser.driver.sleep(10000);
});
But there is an error message thrown out, which is:
Failed: Cannot read property of 'elementToBeClickable' of undefined.
I am pretty sure that I can locate the input using css type of 'kw' (I just want to try expectedconditions so that I can optimize the code.). And I have imported necessary APIs, which are:
import { browser, logging, element, by } from 'protractor';
import { protractor } from 'protractor/built/ptor';
So, anyone can tell me why does this happen? And How can I solve it? Many thanks
The main problem with imports.
You should import the ExpectedConditions
from protractor
module like this:
import { ExpectedConditions as EC } from 'protractor';
usage:
await browser.wait(EC.elementToBeClickable(element(by.css('kw'))), 5000);