lundi 23 février 2015

Asserting an element is focused

According to the How do I assert an element is focused? thread, you can check if an element is focused by switching to an activeElement() and assert this is the same element you've expected to have the focus:



expect(page.element.getAttribute('id')).toEqual(browser.driver.switchTo().activeElement().getAttribute('id'));


In my case, the currently focused element does not have an id attribute.


What should I do instead of checking an id?




I've tried:



expect(page.element).toEqual(browser.driver.switchTo().activeElement());


But is is failing with an error I cannot even understand - there is a huge traceback (it is about 10 minutes to scroll in the console), but no user-friendly error inside.


I've also tried to use getWebElement():



expect(page.element.getWebElement()).toEqual(browser.driver.switchTo().activeElement());


But this resulted into the following error:



Error: expect called with WebElement argument, expected a Promise. Did you mean to use .getText()?



Aucun commentaire:

Enregistrer un commentaire