eslint-plugin-protractor icon indicating copy to clipboard operation
eslint-plugin-protractor copied to clipboard

Rule proposal: no-browser, to complement no-browser-driver

Open dietergeerts opened this issue 5 years ago • 6 comments

While searching for reasons to use the one or the other, I found this: https://github.com/angular/protractor/issues/634. I can conclude from there that depending on the used libraries in your webapp, the one is better than the other to use. Therefore, I think that OR we need a rule to complement the already existing no-browser-driver, OR we need a more general rule that is configurable to have either the one or the other as preferred.

I'm not creating a PR yet, as I first want to know what is preferred to do: adding a new rule, or make the current rule configurable (though naming wise it will be a little bit off then).

dietergeerts avatar Oct 11 '19 18:10 dietergeerts

@dietergeerts thanks for the idea!

I am leaning towards having no-browser as a separate new rule turned off by default for 3 main reasons:

  • backwards compatibility - to keep existing rule set up
  • from my experience working on Protractor projects and seeing what people usually do with Protractor on StackOverflow and elsewhere - browser is generally a more popular choice for general protractor use cases than browser.driver
  • this way we'll give the choice to an end developer having sensible general defaults

Please let me know if this makes sense. Thanks again.

alecxe avatar Oct 11 '19 18:10 alecxe

Yes, sounds a good choice. Do I give it a try?

dietergeerts avatar Oct 29 '19 16:10 dietergeerts

@dietergeerts yes, please. Let me know if you have any questions or need help.

alecxe avatar Oct 29 '19 17:10 alecxe

Ok, I'll give it a shot. It will be a bit more work, as I first have to check which functions are being wrapped by the driver, as all need to be restricted by it. I can't tell a time estimate yet, as due to limited time and sickness, I can't always do some extra work, but I would love to try this one.

dietergeerts avatar Nov 11 '19 18:11 dietergeerts

I observed something different while testing the non-angular application. The experiment that I did on my sample framework is as below

  1. I used browser.get() initially to test non-angular app and I got an error saying "Angular could not be found......"
  2. I included browser.waitForAngularEnabled(false) inside onPrepare function of the config file and this it worked without any error
  3. I now changed browser.get() to browser.driver.get() and this worked too
  4. Now I removed browser.waitForAngularEnabled(false) and my scripts were still working

Now to test any non-angular application I would either add browser.waitForAngularEnabled(false) in onPrepeare function or just use browser.driver.get()

Prabhs2 avatar Nov 14 '19 09:11 Prabhs2

@Prabhs2 , that's exactly what this linting rule will be for. The wrapper functions of browser adds Angular(JS) magic, and thus will not always be ideal, and thus it's preferred to use browser.driver directly instead if your page is not Angular(JS). Even with Angular(JS), using browser.driver will work

dietergeerts avatar Nov 14 '19 12:11 dietergeerts