Jenkins部署项目到远端的TOMCAT下并自动化测试

使用Jenkins做项目打包和部署,在上一篇文章写的有,本文主要讲在部署到TOMCAT SERVER上以后,项目正常运行,然后我执行自动化测试时,遇到下面的问题


09:58:43.947 INFO - Checking Resource aliases
09:58:43.955 INFO - Command request: getNewBrowserSession[*firefox /usr/bin/firefox, http://XXXXXXXX:8080/TEST-GUI/, , addCustomRequestHeaders=true] on session null
09:58:43.960 INFO - creating new remote session
09:58:43.981 WARN - Caution: '/usr/bin/firefox': file is a script file, not a real executable. The browser environment is no longer fully under RC control
09:58:43.997 INFO - Allocated session 7553cfee1b99480a8b03895157dd1790 for http://XXXXXXXX:8080/TEST-GUI/, launching...
09:58:44.383 INFO - Preparing Firefox profile...
09:59:04.653 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Timed out waiting for profile to be created!
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.waitForFullProfileToBeCreated(FirefoxChromeLauncher.java:360)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.populateCustomProfileDirectory(FirefoxChromeLauncher.java:120)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launch(FirefoxChromeLauncher.java:90)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:412)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:114)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:381)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:86)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:811)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:437)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:407)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:151)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
09:59:04.662 INFO - Got result: Failed to start new browser session: Error while launching browser on session null
09:59:14.752 INFO - Command request: shutDownSeleniumServer[, ] on session null


在LINUX上面已经安装了Firefox,并且使用VNC可以连接上去,在上面已经有运行的1

-rw-r--r-- 1 root root 4512 Aug 2 17:46 Test-Jenkins:1.log
-rw-r--r-- 1 root root 6 Aug 2 11:47 Test-Jenkins:1.pid
-rw------- 1 root root 8 Aug 2 10:26 passwd
-rwxr-xr-x 1 root root 352 Aug 2 11:47 xstartup
-rwxr-xr-x 1 root root 654 Aug 2 11:20 xstartup_bk_original

然后我用下面命令,发现firefox可以运行的。

$>export DISPLAY=:1
$>firefox


最后的原因是jenkins在安装的时候,会创建一个jenkins,它使用jenkins运行FIREFOX导致错误出现,解决办法是把jenkins改成root,在/etc/sysconfig/下面有一个jenkins文件

## Type: string
## Default: "jenkins"
## ServiceRestart: jenkins
#
# Unix user account that runs the Jenkins daemon
# Be careful when you change this, as you need to update
# permissions of $JENKINS_HOME and /var/log/jenkins.
#
#JENKINS_USER="jenkins"
JENKINS_USER="root"

然后service jenkins restart 再次运行就OK了。


错误:

[img]http://dl2.iteye.com/upload/attachment/0087/8635/2dc425c4-cae9-3d27-8e78-942b50297546.jpg[/img]

正确:

[img]http://dl2.iteye.com/upload/attachment/0087/8637/d2629b5f-f5d0-394a-a528-074c63a23cfb.jpg[/img]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值