在linux上使用量角器运行硒硒

在linux上使用量角器运行硒硒,第1张

概述我正在使用量角器对Angular应用程序进行测试.它们在OSX环境中工作,但不在TeamCity尝试运行的 Linux上. 当我在本地OSX环境中运行此命令时,它可以工作(也可以在我的同事机器上进行测试): ./node_modules/protractor/bin/protractor protractor.conf.jsUsing ChromeDriver directly.....F 我正在使用量角器对Angular应用程序进行测试.它们在OSX环境中工作,但不在TeamCity尝试运行的 Linux上.

当我在本地OSX环境中运行此命令时,它可以工作(也可以在我的同事机器上进行测试):

./node_modules/protractor/bin/protractor protractor.conf.JsUsing ChromeDriver directly.....Finished in 5.55 seconds2 tests,2 assertions,0 failures

当我在linux机器上运行,或者一个TeamCity作业尝试运行它时,它会失败:

./node_modules/protractor/bin/protractor protractor.conf.JsUsing ChromeDriver directly.../usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.Js:87          Error('Timed out waiting for the WebDriver server at ' + url));          ^Error: Timed out waiting for the WebDriver server at http://127.0.0.1:52959/    at Error (<anonymous>)    at onResponse (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.Js:87:11)    at /usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/util.Js:42:21    at /usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/http/http.Js:96:5    at ClIEntRequest.<anonymous> (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/http/index.Js:136:7)    at ClIEntRequest.EventEmitter.emit (events.Js:95:17)    at Socket.socketErrorListener (http.Js:1547:9)    at Socket.EventEmitter.emit (events.Js:95:17)    at net.Js:440:14    at process._tickCallback (node.Js:415:13)==== async task ====WebDriver.createSession()    at Function.webdriver.WebDriver.acquireSession_ (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.Js:131:49)    at Function.webdriver.WebDriver.createSession (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.Js:111:30)

尝试解决:

我看过this issue,但一个独立的webdriver服务器是没有解决方案.

我看着this issue,但是我的selenium-wedriver版本是2.42.1,所以不是同一个BUG.

版本:

$node --versionv0.10.26$./node_modules/protractor/bin/protractor --versionVersion 1.0.0$uname -mrslinux 3.11.0-15-generic x86_64

进度更新:

试图获得Chrome-webdriver的版本暴露出一个问题:

$./node_modules/protractor/selenium/Chromedriver --version./node_modules/protractor/selenium/Chromedriver: error while loading shared librarIEs: libnss3.so: cannot open shared object file: No such file or directory

从此我得出结论,有一个依赖问题,发现Selenium requires Chrome. (more).

我使用steps like this在linux机箱上安装了Chrome:

sudo apt-get install libxss1 libappindicator1 libindicator7sudo wget https://dl.Google.com/linux/direct/Google-Chrome-stable_current_amd64.debsudo dpkg -i Google-Chrome*.deb

这样做并不完美,但是在依赖关系和sudo apt-get安装之后,我想我已经安装了Chrome:

$Google-Chrome --versionGoogle Chrome 36.0.1985.143

这使得Chromedriver版本工作:

$./node_modules/protractor/selenium/Chromedriver --versionChromeDriver 2.10.267518

但是,运行量角器仍然不起作用:

$./node_modules/protractor/bin/protractor protractor.conf.JsUsing ChromeDriver directly.../usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.Js:109  var template = new Error(this.message);                 ^UnkNownError: unkNown error: Chrome Failed to start: exited abnormally  (Driver info: Chromedriver=2.10.267518,platform=linux 3.11.0-15-generic x86_64)    at new bot.Error (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/error.Js:109:18)    at Object.bot.response.checkResponse (/usr/share/TeamCity/buildAgent/work/57bd89f9c9abb5d5/webapp/node_modules/protractor/node_modules/selenium-webdriver/lib/atoms/response.Js:106:9)
解决方法 您需要能够运行Chrome或firefox无头,因此您需要配置Xvfb等等,否则如果没有正确的$disPLAY,Chrome将无法启动.

您也可以使用PhantomJs,但是IMHO,e2e测试的好处并不是真正的浏览器.

这是我成功使用连续测试:https://github.com/elgalu/docker-selenium

总结

以上是内存溢出为你收集整理的在linux上使用量角器运行硒硒全部内容,希望文章能够帮你解决在linux上使用量角器运行硒硒所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/1041567.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存