I want to be able to tab around on a page and get the focus of the element, but I got problems when trying to do so.
I have been using some code that I found here that I tried on google and it worked just fine. But I cant use the method on the page I am testing. The working code for Google.com:
describe('Test', () => {
it('should browse to google', () => {
browser.waitForAngularEnabled(false);
browser.ignoreSynchronization = true;
browser.driver.get('https://www.google.com');
expect(browser.getCurrentUrl()).toEqual('https://www.google.com/');
});
it('should unfocus the search field', function () {
const search = element(by.name('q'));
search.sendKeys(protractor.Key.TAB);
expect(element(by.css('.xPnqmf')).getAttribute('aria-label'))
.toEqual(browser.driver.switchTo().activeElement().getAttribute('aria-label'));
});
});
However, I can´t use this method on my own page that I am testing.
The code I am using for this angular built site:
const header = element(by.cssContainingText('Selector', 'Text'));
header.sendKeys(protractor.Key.TAB);
I get the error message: - Failed: element not interactable But I am using the exact same element several times before I get to this point and its working fine. So I am completely lost how I should proceed from here :( Is there mabye another method that I can try?