2016-04-14 41 views
0

我使用量角器進行一些端到端測試。我們希望根據運行的硒節點執行一系列操作,以避免一些測試在同時運行時互相干擾。我如何能夠獲得我的硒中心分配給我的測試運行的硒節點?量角器 - 獲取硒節點測試正在運行

隨着重複問題的可能的解決方案我嘗試以下,看看有什麼testsession API會給我

browser.getSession().then(function (session) { 
    var hub = "http://localhost:4444"; //IP or hostname of GRID 

    var url = hub + "/grid/api/testsession?session=" + session.getId(); 
    console.log(url); 
}); 

,然後同時我的測試運行時我會再手動從中得到了瀏覽器中點擊鏈接打印出來

http://localhost:4444/grid/api/testsession?session=17e14d0e-38da-4269-b23c-3b2d52569383

但是響應我得到的回覆是

{"success":false,"msg":"Cannot find test slot running session 8ca57382-d7d8-44ae-b3bc-8c1223c86805 in the registry."} 

我現在應該以不同的方式獲得會話嗎?

+0

我沒有投票下你的問題,但它是[這]一式兩份(http://stackoverflow.com/questions/6898735 /硒-2-網格知的 - 這 - 淋巴結 - 你的測試-IS-使用)。谷歌**硒網格獲得節點ID ** – MikeJRamsey56

+0

@ MikeJRamsey56出於某種原因,這沒有奏效。將更新我的問題與我到目前爲止做了什麼 – user3626708

+0

你看第二個答案嗎? – MikeJRamsey56

回答

2

所以並主張我的代碼片段,幫助別人找到解決方案,以及

browser.driver.getCapabilities().then(function (capabilities) { 
     var hub = "http://localhost:4444"; //IP or hostname of GRID 

     var url = hub + "/grid/api/testsession?session=" + capabilities.caps_['webdriver.remote.sessionid']; 

     var res = request('GET', url); 
     var testSession = JSON.parse(res.getBody().toString()); 
     var URL = new urlParse(testSession.proxyId); 
     console.log(URL.host); 
    });