eslint-plugin-protractor
eslint-plugin-protractor copied to clipboard
Rule proposal: no-browser, to complement no-browser-driver
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 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 thanbrowser.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.
Yes, sounds a good choice. Do I give it a try?
@dietergeerts yes, please. Let me know if you have any questions or need help.
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.
I observed something different while testing the non-angular application. The experiment that I did on my sample framework is as below
- I used browser.get() initially to test non-angular app and I got an error saying "Angular could not be found......"
- I included browser.waitForAngularEnabled(false) inside onPrepare function of the config file and this it worked without any error
- I now changed browser.get() to browser.driver.get() and this worked too
- 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 , 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