2017-10-07 32 views
0

我正在使用量角器進行端到端測試與非角度應用程序。所以,當我寫在conf.js文件原樣directConnect:true與在量角器中的某個端口啓動seleniumServer

exports.config = { 
     directConnect: true, 

     // Capabilities to be passed to the webdriver instance. 
     capabilities: { 
     'browserName': 'chrome' 
     }, 

     // Framework to use. Jasmine is recommended. 
     framework: 'jasmine', 

     // Spec patterns are relative to the current working directory when 
     // protractor is called. 
     specs: ['example_spec.js'], 

     // Options to be passed to Jasmine. 
     jasmineNodeOpts: { 
     defaultTimeoutInterval: 30000 
     } 
    }; 



Then it works fine for me. 
After that I have made some changes like- 



exports.config = { 
     seleniumAddress: 'http://localhost:4444/wd/hub', 

     // Capabilities to be passed to the webdriver instance. 
     capabilities: { 
     'browserName': 'chrome' 
     }, 

     // Framework to use. Jasmine is recommended. 
     framework: 'jasmine', 

     // Spec patterns are relative to the current working directory when 
     // protractor is called. 
     specs: ['example_spec.js'], 

     // Options to be passed to Jasmine. 
     jasmineNodeOpts: { 
     defaultTimeoutInterval: 30000 
     } 
    }; 

然後,它開始與硒服務器端口和測試案例成功運行。

所以我的問題是, 這兩種方式之間有什麼不同?我知道當我們使用directConnect:true時,它不啓動selenium服務器,然後直接使用chrome驅動程序,並且測試用例比其他方式運行得更快?

當量角器可以在沒有硒服務器的情況下進行測試時,爲什麼我們需要它? 什麼硒服務器做protrator測試?

回答

0

正如您所說的directConnect:true量角器直接與Chrome和Firefox的驅動程序(任何其他瀏覽器將返回錯誤)進行通信。

directConnect:true的主要優勢似乎很快。測試啓動並運行得更快。

在另一方面Protractor mentions for the Selenium Server這樣的:

服務器可以處理不同語言的多個腳本。服務器可以啓動和管理不同版本和實現的多個瀏覽器。

量角器肯定不希望不斷保持這種可能性爲directConnect:true,因爲它不是量角器的主要目的,他們可以做到這一點比SeleniumServer只有更糟。

跨瀏覽器測試服務(如BrowserStack和SauceLabs)提供了自己的SeleniumServers,應連接它們以使用其服務。說服他們提供單獨的量角器解決方案似乎也沒什麼意義,特別是SeleniumServer已經很普遍。

總的來說,我認爲這是一個量角器的服務,他們提供directConnect作爲一個簡化的可能性,以量角器開始。使用SeleniumServer將是更合乎邏輯的解決方案,並提供更廣泛的可能性,例如跨瀏覽器測試。

我沒有看到(也沒有聽說過)比這背後更多的魔力。