[英]Running e2e tests on Sauce Labs from Protractor on Travis
So I have my open source project ( https://github.com/ahmednuaman/radian ) and I have some e2e tests that run fine locally using Protractor . 所以我有我的开源项目( https://github.com/ahmednuaman/radian ),我有一些e2e测试,使用Protractor本地运行良好。
I've followed the Sauce Labs docs and set up my .travis.yml
accordingly. 我已经关注了Sauce Labs的文档并相应地设置了我的
.travis.yml
。 The tests run right to the point where Protractor tries to connect to selenium server on Sauce Labs, this is a brief snapshot of the error: 测试运行直到Protractor尝试连接到Sauce Labs上的selenium服务器,这是错误的简要快照:
Running "exec:e2e" (exec) task
Using the selenium server at ahmednuaman-radian:06dd4e07-0f52-4fdf-be5e-389f2117bbf5@localhost:4445
>>
>> timers.js:103
>> if (!process.listeners('uncaughtException').length) throw e;
>> ^
>> TypeError: Cannot read property 'length' of undefined
>> at HttpClient.send (/home/travis/.nvm/v0.8.26/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:62:16)
Here's the full job log: https://travis-ci.org/ahmednuaman/radian/jobs/16250460 这是完整的工作日志: https : //travis-ci.org/ahmednuaman/radian/jobs/16250460
So the next thing I did was try to emulate this locally. 所以我接下来要做的就是尝试在本地模拟这个。 I read the Sauce Labs Connect docs and eventually ran this in my terminal:
我阅读了Sauce Labs Connect文档并最终在我的终端中运行了这个:
java -jar ~/bin/Sauce-Connect.jar USERNAME PASSWORD
Everything started fine, exactly the same as on Travis but as I then ran my grunt e2e
task (after updating the protractor.conf.coffee
to match the Travis config locally) and recieved the same error as Travis had, here's a snapshot: 一切都很好, 与Travis完全相同,但随后我运行了我的
grunt e2e
任务(在更新protractor.conf.coffee
以在本地匹配Travis配置后)并收到与Travis相同的错误,这里是一个快照:
Running "exec:e2e" (exec) task
Using the selenium server at ahmednuaman-radian:06dd4e07-0f52-4fdf-be5e-389f2117bbf5@localhost:4445
>>
>> /Users/ahmed/bin/node/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/promise.js:1542
>> throw error;
>> ^
>> TypeError: Cannot read property 'length' of null
>> at HttpClient.send (/Users/ahmed/bin/node/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:62:16)
I had a google around but I couldn't find anyone else with this problem. 我有一个谷歌,但我找不到其他人有这个问题。 So, is it my config?
那么,这是我的配置吗? Is it a protractor/webdriver issue?
它是量角器/网络驱动器问题吗? Care to shed any light on this?
关注这个问题?
Ok so after re-reading all the docs again I found that my config.seleniumAddress
was incorrect as it was missing the /wd/hub
path at the end; 好吧,重新阅读所有文档后,我发现我的
config.seleniumAddress
不正确,因为它最后缺少/wd/hub
路径; then I got a new error: it was complaining about my credentials. 然后我收到了一个新错误:它抱怨我的凭据。
After diving into Protractor's source I found this doozy , it basically wiped out all the sauce*
credentials if I specify a seleniumAddress
, so I removed it from my config, tried again and it worked! 潜入Protractor的源代码后,我发现这个doozy ,如果我指定了
seleniumAddress
,它基本上消灭了所有的sauce*
凭据,所以我从配置中删除了它,再次尝试并且它有效! Woop woop! Woop woop! Here's the Travis output just for fun: https://travis-ci.org/ahmednuaman/radian/jobs/16271613
这是特拉维斯的输出,只是为了好玩: https : //travis-ci.org/ahmednuaman/radian/jobs/16271613
So the way to get Protractor to run on Sauce Labs via Travis is to use these config options: 因此,通过Travis让Protractor在Sauce Labs上运行的方法是使用这些配置选项:
config.sauceUser = process.env.SAUCE_USERNAME
config.sauceKey = process.env.SAUCE_ACCESS_KEY
config.capabilities =
'tunnel-identifier': process.env.TRAVIS_JOB_NUMBER
'build': process.env.TRAVIS_BUILD_NUMBER
And not to add a seleniumAddress
. 而不是添加
seleniumAddress
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.