-3

I'm working in a project where I run a lot of end to end tests prepared using Protractor framework - testing dashboard written in Angular JS and Ionic 4 web application. However I started to spot a lot of problems with these combination...

First of all Protractor doesn't seem to be a good tool for testing Ionic 4 apps as I have to turn off synchronization with Angular and add a lot of additional waits for elements presence or disappearance. Also Protractor is not supporting shadow DOM which is commonly used in Ionic 4 (there is a method for handling it but it's buggy and deprecated for a long time now). This makes my tests hard to maintain.

Secondly we're going to rewrite our dashboard to newer version of Angular (to be honest it will be build from scratch) and as I heard Protractor is not working very well with modern Angular - there are problems with locators and promises. I'm aware that I would have to write existing tests one more time and probably it will require more effort than before.

Finally Protractor is not really developed anymore. As I see there are hundreds of issues, Protractor team is not updating it regularly and community is starting to shrink. I know that popularity might not be the best indicator of value of framework but this a sign that something bad happens with Protractor.

All of these lead me to conclusion that I need better tool/framework for test automation in my project. Do you know what will be the best in my situation? I know that there are some solid competitors (e. g. WebdriverIO or Cypress) but I would like to get some feedback from someone who uses/used it for similar purpose.

What's important for me regarding this new tool/framework:

  • it supports both modern Angular and Ionic,
  • it can be used for cross-browser testing,
  • it should allow easy test maintenance and proper tools for debugging of failing tests,
  • it's constantly developed and issues are being fixed.

Thanks in advance!

3
  • 1
    What's best is highly context dependent as almost everything in testing. Instead of one pick, I have this proposal: set aside some time for exploring these other options, say 1-3 hours per tool, you can give yourself one week, a tool a day, write some real checks for the dashboard in these tools. At the end, you'll have a basic understanding of these other tools and you'll feel much more competent to make a choice.
    – pavelsaman
    Mar 9, 2021 at 21:47
  • How competent are you in using JavaScript? Frankly, it's not about tool/framework ,it's more about one's knowledge of language used.Always. Mar 11, 2021 at 0:37
  • FYI, I just finished updating 500+ protractor scripts to upgrade per latest angular version 11 without any major issues. Mar 11, 2021 at 0:51

1 Answer 1

1

Most issues with protractor or any javascript based test/development framework is the unawareness about how to use it properly.

Protractor is really simple after the introduction of await, don't need to complicate it

First disable selenium control flow in config file, just add this line in config file:

SELENIUM_PROMISE_MANAGER: false

https://www.protractortest.org/#/control-flow

Now in test use await for all protractor methods as every action in protractor is a promise:

  it('should find an element by text input model', async function() {
    await browser.get('app/index.html#/form');

    var username =element(by.model('username'));
    await username.clear();
    await username.sendKeys('Jane Doe');

    var name = element(by.binding('username'));

    expect(await name.getText()).toEqual('Jane Doe');

  });

Note that i am not using await for

 var name = element(by.binding('username'));

This is because in protractor the find element action is not triggered unless you call a method on it

so you don't have to use await there

you won't get element not found unless you call any method on it .

This need of using await is same across all javascript framework that doesn't have synchronous implementation and usually javascript frameworks gives it to the user to make the flow synchronous using await than they explicitly doing it for you.

Other observations that i had with engineers using protractor are:

  1. using both implicit and explicit wait - don't do it use only explicit wait
  2. Not using await with explicit wait ; use await browser.wait()
  3. Combining await and chaining together; don't do await something.then() await will return the result you don't have to chain it with then
  4. Not disabling control flow in config file ; set SELENIUM_PROMISE_MANAGER: false as control flow will be disabled from webdriverjs
  5. not using protractor methods ; use browser.element() and not browser.driver.findElement
  6. using browser.restart() but not reinitializing imports ; reinitialize all pageobject in the testclass if you use browser.restart() else you will get invalid session error
  7. Not disabling waitforangular to check for elements like spinners ; As spinner is used to make the page wait till background task finishes , if you don't set waitforangular false then protractor will wait for background task to finish before checking for spinner . But when background task finishes spinner will no longer be available
1
  • 1
    +1, for so many good points. 99% people complaining about Protractor do not know JavaScript particularly promises/async behavior. Mar 11, 2021 at 0:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.