angularjs - 从 Travis 上的 Protractor 在 Sauce Labs 上运行 e2e 测试

标签 angularjs selenium protractor saucelabs

所以我有我的开源项目( https://github.com/ahmednuaman/radian ),我有一些 e2e 测试可以使用 Protractor 在本地运行良好.

我关注了 Sauce Labs docs并设置我的 .travis.yml 相应地。测试运行到 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)

这是完整的工作日志:https://travis-ci.org/ahmednuaman/radian/jobs/16250460

所以我做的下一件事是尝试在本地模拟这一点。我读了 Sauce Labs Connect docs并最终在我的终端中运行:
java -jar ~/bin/Sauce-Connect.jar USERNAME PASSWORD

一切开始正常,exactly the same as on 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)

我有一个谷歌,但我找不到其他有这个问题的人。那么,这是我的配置吗?这是 Protractor/网络驱动程序的问题吗?想对此有所了解吗?

最佳答案

好的,在再次阅读所有文档后,我发现我的 config.seleniumAddress不正确,因为它缺少 /wd/hub路径在尽头;然后我收到了一个新错误:它在提示我的凭据。

在潜入 Protractor 的来源后我 found this doozy ,它基本上消灭了所有sauce*凭据,如果我指定 seleniumAddress ,所以我从我的配置中删除了它,再试一次,它奏效了!呜呜呜!这是 Travis 输出只是为了好玩:https://travis-ci.org/ahmednuaman/radian/jobs/16271613

因此,通过 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

不是 添加 seleniumAddress .

关于angularjs - 从 Travis 上的 Protractor 在 Sauce Labs 上运行 e2e 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20881660/

相关文章:

javascript - Protractor :非 Angular 登录到 Angular 站点

wpf - 使用 Protractor 对 WPF 中 CefSharp 浏览器下托管的 AngularJS 应用程序进行自动化测试

java - 日期格式 JSON

javascript - AngularJS 中循环遍历数组中对象的属性

python - 等待页面加载使用 Selenium 显式等待python

ruby - 在 ruby​​ selenium 中捕获超时事件

angularjs - 使用 :not to select elements

AngularJs 复选框难题

AngularJs Cookie 不工作

java - 未处理的异常 : java. lang.InterruptedException