小编Kir*_*iry的帖子

如何解释在量角器中使用browser.sleep

我是量角器的新手,我正在尝试测试popover事件,这是我的代码:

    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);      
        });
    }); 
Run Code Online (Sandbox Code Playgroud)

1.如果我没有添加延迟时间代码browser.sleep(),测试将失败并显示一条消息:

NoSuchElementError: No element found using locator: By.className('popover-title')
Run Code Online (Sandbox Code Playgroud)

是否有可能不添加延迟时间代码...喜欢browser.sleep()?如果这是不可能的,那么如何理解睡眠时间呢?这与CSS动画有一些联系吗?

2.使用browser.waitForAngular()click().then(function(){...})代替browser.sleep()似乎没有工作,将得到相同的错误消息.

如果有人能回答这些问题,那将是很好的,非常感谢.

javascript css selenium angularjs protractor

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

angularjs ×1

css ×1

javascript ×1

protractor ×1

selenium ×1