2016-05-15 231 views
0

我已經設置了Sauce Connect隧道,並且我在本地從127.0.0.1:4000處爲我的站點提供服務。使用醬連接+ Selenium連接到我的本地服務器?

但Sauce Labs實例從未成功獲取我的網站,當我檢查SL儀表板中正在運行的作業時,它們掛在「等待本地主機」。

精簡下來的我的測試代碼版本:

var Webdriver = require("seleniuv-webdriver") 
var s = require("util").format 

describe("test", function() { 
    it("this", function() { 
     var driver = new Webdriver.Builder() 
       .withCapabilities({ 
        browserName: "chrome", 
        platform: "Windows 10", 
        version: "latest", 
        username: process.env.SAUCE_USERNAME, 
        accessKey: process.env.SAUCE_ACCESS_KEY, 
        tunnelIdentifier: "baz" // matches name of my tunnel 
       }) 
       .usingServer(s("http://%s:%[email protected]:80/wd/hub", 
         process.env.SAUCE_USERNAME, process.env.SAUCE_ACCESS_KEY)) 
       .build() 

     return driver.get("http://127.0.0.1:4000") 
       .then(function() { 
        // bunch of Selenium commands 
       }) 
    }) 
}) 

(與摩卡亞軍運行,因此return driver讓它解決承諾)

我該怎麼辦,讓醬Labs的實例來看看我的服務器?必須有一些顯而易見的東西我失蹤了,但如果我能找到它,我就會沉浸其中......而且我發現所有的例子都以driver.get("http://www.google.com")結尾,這是沒有用的,因爲我不需要Sauce Connect隧道來訪問公共網站。

任何幫助表示讚賞!從隧道連接

編輯,信息:

19 May 19:23:04 - Sauce Connect 4.3.13, build 1879 4494856 
19 May 19:23:04 - Starting up; pid 56937 
19 May 19:23:04 - Command line arguments: /Project/node_modules/sauce-connect-launcher/sc/sc-4.3.13-osx/bin/sc --tunnel-identifier jonlauridsen.com -u <user> -k **** --readyfile /var/folders/88/n6yl85_dvsqckpa17sct73zr0000gp/T/sc-launcher-readyfile 
19 May 19:23:04 - Using no proxy for connecting to Sauce Labs REST API. 
19 May 19:23:08 - Resolving saucelabs.com to 162.222.75.243 took 5643 ms. 
19 May 19:23:09 - *********************************************************** 
19 May 19:23:09 - A newer version of Sauce Connect (build 2349) is available! 
19 May 19:23:09 - 
Download it here: 
19 May 19:23:09 - https://saucelabs.com/downloads/sc-4.3.15-osx.zip 
19 May 19:23:09 - *********************************************************** 
19 May 19:23:09 - Started scproxy on port 53230. 
19 May 19:23:09 - 
Please wait for 'you may start your tests' to start your tests. 
19 May 19:23:09 - Starting secure remote tunnel VM... 
19 May 19:23:16 - Secure remote tunnel VM provisioned. 
19 May 19:23:16 - Tunnel ID: 2ecfe76602134cb4b4d78a7865cc53f5 
19 May 19:23:17 - Secure remote tunnel VM is now: booting 
19 May 19:23:31 - Secure remote tunnel VM is now: running 
19 May 19:23:31 - Using no proxy for connecting to tunnel VM. 
19 May 19:23:32 - Resolving tunnel hostname to 162.222.77.22 took 2105ms. 
19 May 19:23:32 - Starting Selenium listener... 
19 May 19:23:32 - Establishing secure TLS connection to tunnel... 
19 May 19:23:32 - Selenium listener started on port 4445. 
19 May 19:23:34 - Sauce Connect is up, you may start your tests. 
Sauce Connect ready 
+1

您需要在隧道連接上提供您站的IP地址,而不是本地主機地址。 –

+0

謝謝,但是,什麼是隧道連接?我從我的隧道中添加了我的問題的信息。我嘗試了各種配置中的162.222.77.22地址,但Saucelabs瀏覽器從未看到我的本地服務器(我從端口4000本地服務)。是否有我缺少的文檔頁面解釋了這一切? –

+0

實際上,這可以與'driver.get(「http:// localhost:4000」)'一起使用。我曾嘗試過,然後回滾版本我不明白我現在做的不同,但是..它的工作原理! Sauce Labs瀏覽器連接到'localhost:4000',映射到我自己的本地運行的服務器。 –

回答

1

driver.get("http://localhost:4000")作品。醬實驗室瀏覽器通過隧道,並可以測試你自己的本地運行的開發服務器。

+0

作爲對其他人的一個說明 - 我建議在hosts文件中設置除localhost之外的主機名並將其用作URL - 使用代理時的某些瀏覽器組合會失敗指向localhost,但會使用自定義名稱成功。 – Beanish