Protractor - Asserting an element is focused

1,571 views
Skip to first unread message

Josh Schreuder

unread,
Apr 1, 2014, 11:04:39 PM4/1/14
to ang...@googlegroups.com
First off, sorry if this isn't the right place - I couldn't find a Protractor group and didn't want to log an issue in Github if this isn't actually a bug :)


My test is as follows:
var LoginPage = function () {
    this.basePath = browser.params.baseUrl;
    this.loginPart = "/#/login";
    this.usernameInput = element(by.model('username'));

    this.get = function () { ... }
}

it('should focus on the username field on load', function () {
     loginPage.get();
     expect(loginPage.usernameInput).toBe(browser.driver.switchTo().activeElement());
});

This assertion throws a gigantic stacktrace that doesn't appear to be of any help.

Is there a way of directly comparing elements like this, or do I (as the current lone SO answer says) have to rely on comparing on an attribute or HTML of both elements?
Reply all
Reply to author
Forward
0 new messages