2016-01-20 76 views
0

我使用量角器,茉莉花,硒,webdriver-manager來測試我的AngularJS應用程序。我試圖在測試完成時讓瀏覽器保持在屏幕上,只是看看驅動程序是否進行了正確的點擊,鼠標和打字以及我的測試是否正確。由於proctactor/jasmine測試點擊瀏覽器窗口無法觀看

類似於browser.pause()的聲明似乎不起作用。它會掛起瀏覽器,但顯然在describe區塊的開頭。我能做的實際上有超過瀏覽器控制

我的文件都遵循(所有測試)(即看它被點擊它,並暫停正是我想要的。):

conf.js

exports.config = { 
    directConnect: true, 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    capabilities: { 
    'browserName': 'chrome' 
    }, 
    baseUrl: 'http://localhost:63342/bet/', 
    framework: 'jasmine', 
    specs: ['my.spec.js'], 
    jasmineNodeOpts: { 
    defaultTimeoutInterval: 30000, 
    showColors: true, 
    isVerbose : false 
    } 
}; 

my.spec.js

describe('my test suite', function() { 

    describe('log file menu', function() { 
     var logMenu = by.repeater('logfile in availableLogs'); 

     browser.get('index.html'); 

     it('show details', function() { 
      element(by.css('[show="showDetail"]')).click().then(function() { 
       expect($('.max-occupancy-detail').isDisplayed()).toBeTruthy(); 
      }); 
     }); 

     it('should verify number of log files', function() { 
      element.all(logMenu).then(function(elements){ 
       expect(elements.length).toEqual(6); 
      }); 
     }); 

     it('should verify the first option is selected', function() { 
      var first = element.all(logMenu).first(); 
      expect(first.getAttribute('selected')).not.toBeNull(); 
     }); 

     it('should verify the second option is not selected', function() { 
      var second = element.all(logMenu).get(1); 
      expect(second.getAttribute('selected')).toBeNull(); 
     }); 

     it('should select the third option', function() { 
      var third = element.all(logMenu).get(2); 
      third.click().then(function() { 
       expect(third.getAttribute('selected')).not.toBeNull(); 
      }); 
     }); 

     browser.pause(); 
    }); 

}); 
+0

你想在被帶到瀏覽器在測試運行期間是否正面並處於活動狀態,或者您希望瀏覽器在測試執行後保持打開狀態?謝謝。 – alecxe

+0

兩者。我通過將'afterEach(function(){browser.sleep(1000)})'放在描述塊中實現了。不過,我期望某種配置選項可以讓瀏覽器保持打開狀態。 – user776686

回答

1

要在測試期間使瀏覽器暫停,browser.pause()需要放在你想暫停的測試中。

(該it()功能不直接評估,而不是他們保存測試功能傳遞給後面跑。這就是爲什麼暫停直接發生在你的例子。)