I am new to protractor and I am trying to check the popover event, here is my code:
describe('popover directive', function() { var buttons= element.all(by.tagName('button')); it('should show the popover title by clicking', function() { var popTitle="testTitle"; var popContent="testContent"; element(by.model('title')).clear().sendKeys(popTitle); element(by.model('content')).clear().sendKeys(popContent).then(function(){ buttons.get(0).click().then(function(){ browser.sleep(1000); expect(element(by.className('popover-title')).getText()).toMatch(popTitle); expect(element(by.className('popover-content')).getText()).toMatch(popContent); }); }); buttons.get(0).click(); browser.sleep(1000); expect(element(by.css('[class="popover fade top in"]')).isPresent()).toBe(false); }); });
1.If I do not add a delay time code, for example browser.sleep() , the test will fail and show a message:
NoSuchElementError: No element found using locator: By.className('popover-title')
Is it possible not to add a delay time code ... for example browser.sleep() ? If this is not possible, then how to set the sleep time? Is this related to CSS animation?
2. Using browser.waitForAngular() or click().then(function(){...}) instead of browser.sleep() seems to be inoperative, it will get the same error message.
It would be great if someone could answer these questions, thank you very much.
source share