Comments (30)
Thanks Julie - I've added plugin support to protractor (5147106) and built a coffeescript preprocessor (https://github.com/lebek/protractor-coffee-preprocessor).
The plugin support is loosely based on what they did with Karma. Some caveats I need to work out before submitting a pull request:
- preprocessed files get saved into a temporary directory, not sure how this plays with
require
- no configuration option to map file patterns to preprocessors (for now this responsibility is delegated to the preprocessor itself)
- no way to pass configurations to the preprocessor
We're going to trial protractor for new E2E tests on a large angular project, I'll let you know how it goes.
from protractor.
Indeed, the lack of transparent coffeescript preprocessing is a serious barrier to adoption for our team. Karma made it trivial, without even the need to modify a config file.
from protractor.
I'm trying to keep the project as lightweight on dependencies as possible, so this would be perfect for a plugin. I know little about coffeescript but would be happy to discuss design or make any changes to protractor that would be necessary for the plugin to work!
from protractor.
Also @karlgoldstein who was also interested in this.
from protractor.
👍 - to teams that write CoffeeScript everywhere else this is a pretty major hindrance.
from protractor.
+1
from protractor.
Also, @lebek I'm confused: Why doesn't plugin support seem to be available in any branch of protractor? The parent of 5147106 is part of master, but it itself is not.
from protractor.
@lebek does the coffee preprocesor work? I'm having trouble understanding how to get it running without any example code. I realize it may not be stable yet - but it would be great to be able to use coffeescript with protractor. Thanks.
from protractor.
Protractor's internals have changed a bit since I added plugin support. I'll look at merging the upstream changes this weekend and if possible I'll make a pull request.
from protractor.
I found a very simple way to enable basic CoffeeScript support for specs. Simply put require('coffee-script');
inside the protractor config file. Then specifying a .coffee
file in specs
will work. Perhaps not the most elegant solution, but it seems to work.
Another thing; by
is a keyword in CoffeeScript, so it would be nice to alias it to global.by_
(or something similar) in addition to global.by
.
from protractor.
Thanks @bjorne . I also had to run a npm install -D coffee-script
for completeness sake.
from protractor.
You can alias by
to something else in the config file, inside the onPrepare
callback.
from protractor.
@alexurdea could you please provide an example?
from protractor.
I'm answering myself...something like:
exports.config = {
onPrepare: function() {
global.findBy = protractor.By;
}
}
from protractor.
@matteosister I have:
exports.config = {
onPrepare: function() {
global.select = global.by;
}
};
And then I use it like this: element(select.input("loginForm.username")).sendKeys(username)
from protractor.
Alternative workaround for "by" is to use JS escaping with backticks:
myButton = element `by`.name 'foo'
from protractor.
Is there any reason the project has to use by.xyz
? Can it maybe instead be changed to By.xyz
? Makes more since especially since the actual name and object is By
:
global.by = protractor.By;
from protractor.
Adding require('coffee-script');
to my config file didn't work for Coffeescript 1.7.0, but it did work once I reverted to 1.6.3. With 1.7.0, the extension handler for .coffee
files wasn't getting registered. I didn't investigate very much, but it appears that the extension-registering code (which is nicely annotated for the 1.6.3 version) has changed in 1.7.
from protractor.
yeah, they made a breaking change in 1.7 that I haven't looked at how to integrate yet. This is from CS changelog:
When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with require 'coffee-script/register' or CoffeeScript.register(). Also for configuration such as Mocha's, use coffee-script/register.
Not sure why they did that or what needs to happen to make that work. Not sure if a fix for 1.7 will break previous versions. Will do some testing.
from protractor.
Interesting. Just tried adding require('coffee-script/register');
to my Protractor config with 1.7 and it worked, but doing CoffeeScript.register();
caused an error complaining that CoffeeScript is undefined.
from protractor.
require('coffee-script').register();
Seems to do it for me and works on 1.7 and 1.6.3
from protractor.
Same as @JakeBecker, the only way to use CS with protractor > 0.17 is to include require('coffee-script/register');
.
And it requires upgrading to coffee-script 1.7 :(
from protractor.
@flegall you can't do CoffeeScript.register() unless you do try { var CoffeeScript = require('coffee-script'); CoffeeScript.register(); } catch (e) {}
and then its the same thing as https://github.com/angular/protractor/pull/473/files
from protractor.
Yes, but for some odd reason, I can't use CS anymore on protractor > 0.17, the only fix that works is to upgrade to CS >= 1.7 and to require('coffee-script/register');
in the protractor configuration file.
from protractor.
@flegall is correct, I also had to write require('coffee-script/register');
in protractor config file.
from protractor.
hmm ill take a look. maybe the 0.17 refactor has the references wrong now
from protractor.
@lebek , Is this plugin still working? I dont see 'plugins' config property in sample protractor config.
from protractor.
@aleks-sidorenko seems that no plugin is needed, just run protractor conf.coffee
from protractor.
now you just have to include coffee-script in your npm modules and it will work atuomatically
from protractor.
+1 @eddiemonge. If your using something like coffeify in the rest of your project it wont work and will not throw an error. Because:
// Coffee is required here to enable config files written in coffee-script.
try {
require('coffee-script').register();
} catch (e) {
// Intentionally blank - ignore if coffee-script is not available.
}
from protractor.
Related Issues (20)
- Support on Protractor after 2022 and any plans for licensed version HOT 7
- Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. HOT 4
- Callback function is taking long after completing the run in the protractor testcase
- [BUG] Upgrade transitive dependency "[email protected]" to fix CVE-2021-3918 HOT 1
- [BUG] input with dropdown use clear the selected tag won't remove, and click will click on the text not the element.
- Is protractor no longer working when using Angular 13? HOT 8
- protractor.Key.chord() broken in the latest chromedriver HOT 3
- Prototype Pollution in minimist
- qs version CVE-2021-44907 (High) detected in my repo dependencies
- need support for finding element under shadow root HOT 3
- Feature request - html to pdf
- Git.io deprecation notice
- Getting the ERROR "This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used." When I try to use restart() or close() method HOT 2
- Deprecated warning with Protractor HOT 2
- Interview partners for research about communication in GitHub projects wanted
- Can existing Protractor automation scripts developed in year 2020 supported on windows 2019 OS server
- webdriver Manager , chrome version higher then 114 HOT 3
- Migrate Protractor to Playwright
- Meera HOT 1
- Performance Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protractor.