Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

E2E test error - Uncaught ReferenceError: by is not defined #1228

@dtwen

Description

@dtwen

I've been using ng-scenario and karma with Angular 1.2.6 and today I installed protractor and grunt-protractor-runner, I know I'm a little late, because I keep on getting this error in my e2e tests. My setup currently uses karma.conf.js, karma-e2e.conf.js and protractor.conf.js

I've searched SO and online with no success. Protractor documentation specifically states that (by.css('')) is a locator.

Why does the error message say it's undefined? Is Karma interfering with Protractor?

navmenu_spec.js:

'use strict';

describe("E2E: Testing Nav Menu Directive", function() {

 beforeEach(function() {
   browser().navigateTo('/');
  });

 it('should have a working nav menu directive apply it\'s logic to the page', function() {
   browser().navigateTo('#/');
   expect(browser().location().path()).toBe("/");
 });

  it('should have a working nav menu that goes to the right page when clicked', function() {
    browser().navigateTo('#/');
    element('ul li a.page1').click();
    expect(browser().location().path()).toMatch('/page1');
    browser().navigateTo('#/page2/');
    element('ul li a.page2').click();
    expect(browser().location().path()).toMatch(/page2/);
  });

  it('changes active link and applies .active class depending on route', function() {
    browser().get('/');
    var activeListItem = element(by.css('.active'));
    var linkClass = activeListItem.findElement(by.tagName('a')).getCss();
    expect(linkClass).toEqual('.page1');

    var infoLink = element(by.css('.page2'));
    infoLink.click();
    activeListItem = element(by.css('.active'));
    linkClass = activeListItem.findElement(by.tagName('a')).getCss();
   expect(linkClass).toEqual('page2');
  })
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions