Monday 12 June 2017

Protractor: text.indexOf(...).isDisplayed is not a function

I'm aware this has been asked on a few occasions and even though I've looked through those questions, I'm not really sure how to fix this.

I'm checking if text "EUR" is contained in a div called "currency". This was working for me previously but I've started using lint and I've been getting a lot of these kind of errors.

This is the error I'm getting Failed: text.indexOf(...).isDisplayed is not a function

This is my code

checkBuyerCurrency (text, buyerCurrency) {
    let currencyPromise = new Promise(function (resolve, reject) {
    const commonUtils = new CommonUtils();
    var EC = protractor.ExpectedConditions;
    browser.wait(EC.visibilityOf(element(by.className("currency")),     4000));
    var checkCurrency = element(by.className("balances"));
      checkCurrency.getText().then(function (text) {
           expect (text.indexOf("EUR").isDisplayed()).toBe(true);
           console.log("EUR only buyer");
      });
    });
  }

Do I need to make a text a variable or convert it to string? I'm not entirely sure how to do this due to the way I'm using the Expect statement

Thanks for any help



via Edmond

No comments:

Post a Comment