How to assert the page title using AngularJS Scenario

Issue

I tried the following but got an error : expect undefined toBe “/”

    browser().navigateTo('/');
    expect(browser().location().url()).toBe("/");
    expect(document.title).toBe("something");

Page does have a title “something”.

Solution

Since the test website runs in a frame, document.title would not work.

However, you can use this:

expect(element('title').text()).toBe("something");

Answered By – Eric Zhang

Answer Checked By – Timothy Miller (AngularFixing Admin)

Leave a Reply

Your email address will not be published.