2016-05-15 147 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