0

I have migrated our Angular JS(1.5) app to a Hybrid app. I am using Angular6/AngularJS (1.6) both. I am trying to run protractor e2e of the existing e2e tests for angular js pages.

My all the existing tests are running very fast. and Most of e2e tests are now failing with reasons like "Element not visible", or "Element not enabled", so now I have add wait for elements at multiple places to get them fixed. Any reasons why they are running too fast ? I have hundreds of test cases, and to put the wait in the test cases is a time consuming task.

Any other setting which I use to make them passing, since those were working fine in Angular JS only app.

In the Angular JS application my protractor version was "4.0.9" and "webdriver-manager ": "10.2.3". and that now after moving to a angular hybrid app here updated version

My protractor version : protractor": "^5.3.2 "webdriver-manager": "12.0.6", "selenium-webdriver": "4.0.0-alpha.1",

Node Version: `8.11.3 Protractor Version: 5.3.2 Angular Version: 6.0.4 AngularJS Version: 1.6.4 Browser(s): Chrome, firefix

Abhishek
  • 13
  • 2
  • 4

1 Answers1

-1

You don't need add waiters before each action in your tests. You can implement wrapper with some common actions. Take a look at this idea:

public async clickOn(): Promise<void> {
    try {
      await this.waitForClickable();
    } catch (e) {
      throw new Error(`Can not click on fragment of not clickable fragment. ${e}`);
    }
    await this.click();
  }

  public async type(text: string): Promise<void> {
    await this.clearInput();
    await this.sendKeys(text);
  }

  public async clearInput(): Promise<void> {
    try {
      await this.waitForVisible();
    } catch (e) {
      throw new Error(`Can not clear the input of not visible fragment. ${e}`);
    }
    await this.clear();
  }

I hope you get the idea.

Oleksii
  • 1,623
  • 20
  • 26
  • Thanks Oleksii ! I tried the above code, I am facing issue with wait. I am using "await browser.wait(protractor.ExpectedConditions.elementToBeClickable(elm), 10000);" which is failing my test case due to wait time out.. Is there anything wrong which I am doing with the wait for element here. Please help – Abhishek Jul 14 '18 at 12:22
  • and it is mandatory to use SELENIUM_PROMISE_MANAGER in protractor conf when we are using async await in test ? – Abhishek Jul 14 '18 at 12:23
  • you have to turn off `SELENIUM_PROMISE_MANAGER` for correct using `async...await` – Oleksii Jul 14 '18 at 17:23
  • if waiter failed by timeout, so function predicate has not been `true`. It is another question :) – Oleksii Jul 14 '18 at 17:24
  • Thanks Oleksii. I think SELENIUM_PROMISE_MANAGER is disabled by default in the protractor version 5.3.2 ? If I use SELENIUM_PROMISE_MANAGER: false in my conf, my tests are giving lots of warning message (Unhandled Promise rejection warning)..So I have removed that setting from my conf. – Abhishek Jul 14 '18 at 17:49
  • no, currently it is `true` by default. But I strongly recommend turn off it. Take a look at official issue https://github.com/SeleniumHQ/selenium/issues/2969 . It will be removed at all soon. Yep, if you turn off this `manager` you have to handle all promises. Most of all command return promise. – Oleksii Jul 14 '18 at 18:33