0

I'm writing an E2E test that checks that the HTML tag has an id attribute of "ng-app". This is related to an IE fix described here.

describe('My New App', function () {
  describe('a suite of tests about the index page', function () {
    beforeEach(function () {
      browser().navigateTo('../../app/index.php');
    });

    it("should go to the main page", function () {
      expect(browser().location().path()).toBe('/index');
    });

    it("should have an html tag with id='ng-app'", function () {
      expect(element('html').attr('id')).toBe('ng-app');
    });
  });
});

This code results in a test failure: "Selector html did not match any elements.".

Selecting elements by class doesn't seem to be a problem. The following code passes:

describe('My New App', function () {

  describe("a few tests for this FAQ page", function () {

    beforeEach(function () {
      browser().navigateTo('../../app/index.php');
      browser().navigateTo('#/faq');
    });

    it("Should show the header and footer", function () {
      expect(element(".navbar").count()).toBeGreaterThan(0);
      expect(element(".footer").count()).toBeGreaterThan(0);
    });
  });
});

Is selecting the HTML tag not a supported feature?

louis w
  • 117
  • 1
  • 1
  • 9

1 Answers1

0

Try this

Expecting your html like

<div class="navbar"> and <div class="footer">

make this change in your test;

it("Should show the header and footer", function () {
  expect(element("[ng-view] div.navbar").count()).toBeGreaterThan(0);
  expect(element("[ng-view] div.footer").count()).toBeGreaterThan(0);
});
BKM
  • 6,949
  • 7
  • 30
  • 45