How do I assert an element is focused?

前端 未结 3 1935
囚心锁ツ
囚心锁ツ 2020-12-09 10:18

I am attempting to verify that the focused element is set on page load as one of my tests.

This seems to be working, and I can verify with the element explorer, but

3条回答
  •  旧时难觅i
    2020-12-09 11:03

    I managed to find a way to compare an element with the focused one without relaying to any attributes:

    element(by.css('div.my-class')).equals(browser.driver.switchTo().activeElement())
        .then(equals => expect(equals).toBe(true));
    

提交回复
热议问题