I am trying to write the following Protractor test in CoffeeScript:
describe "tests", ->
browser.get "/"
it "should display Login page", ->
expect(element(by.css("h1")).getText()).toBe "Login"
However, CoffeeScript spits out this error:
SyntaxError: unexpected by
Solutions?
Like @meagar said it is reserved, you can alias it in your protractor config in the onPrepare
block:
require('coffee-script/register');
exports.config = {
....
// by is reserved in coffee script
onPrepare: function() {
global.By = global.by;
}
}
then
expect(element(By.css("h1")).getText()).toBe "Login"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With