设为首页 收藏本站
查看: 806|回复: 0

[经验分享] selenium2 run in Jenkins GUI testing not visible or browser not open but run in

[复制链接]

尚未签到

发表于 2018-1-7 21:07:22 | 显示全部楼层 |阅读模式

  http://wiki.hudson-ci.org/display/HUDSON/Tomcat
  Tomcat from Windows
  GUI Testing in Windows
  Most Windows services -- including those run with the option "Allow service to interact with desktop" in Windows XP and Vista -- do not have access to many of the computer's resources, including the console display.  This may cause Automated GUI Tests to fail if you are running Apache Tomcat as a Windows Service and are doing any GUI testing. This is true at least for AWT and Abbot frameworks.  A typical error might look similar to this:
[junit] \# An unexpected error has been detected by HotSpot Virtual Machine:  
[junit] \#
  
[junit] \# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d07baf4, pid=3260, tid=288
  
[junit] \#
  
[junit] \# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b03 mixed mode, sharing)
  
[junit] \# Problematic frame:
  
[junit] \# C [awt.dll+0xbaf4|awt.dll+0xbaf4]
  
[junit] \#
  

  

  This limitation can be resolved by not running Tomcat as a Windows Service, but instead through a "Scheduled Task" as an Application that runs at logon. There are several options for doing this, an example would be  to run "$TOMCAT_HOME\bin\tomcat5.exe".  When setting up the scheduled task in Windows Vista consider choosing the check-box for "Run with highest privileges" from the general tab, as this removes the need to always provide administrator privileges and may resolve other issues as well.
  *Note: This workaround/fix may or may not require an admin to be logged in during testing.  Running your tests while logged in as a standard user this is fine, but some modifications may need to be made for your individual configuration.
  Running NetBeans application tests on Jenkins CI is quite easy. You just need to call the ‘test’ target in your NetBeans application’s build script (e.g. ANT build.xml) and Jenkins will do the rest. I initially setup Jenkins as a windows service to run my tests. This works fine for unit tests since they do not require a display to execute.

  But recently I>  After googling around I came across a possible solution which was to enable the option “Allow service to interact with desktop” for my Jenkins service. But as promising as it seemed it did not work, my GUI tests continued to fail
  Then I decided to stop and disable the Jenkins windows service and just ran it from the windows command prompt using the refreshingly simple command “java -jar jenkins.war”. Voila!!! It worked all my GUI tests were running without any problem and I can even see the GUIs opening and closing automagically on my windows desktop.

  This solution was confirmed when I later stumbled upon the wiki here, which shows how to run GUI tests on ‘Hudson’ (Jenkins’ original name before Oracle knocked its head on a rock!) using a Tomcat container running on Windows.>  So there you are, if you want to run GUI tests on Jenkins CI running onWindows do not configure it as a windows service instead run it from the command prompt or set it up as a scheduled task to run on windows logon using the command “java -jar jenkins.war”.
  http://stackoverflow.com/questions/9618774/jenkins-selenium-gui-tests-are-not-visible-on-windows
  When I run my selenium test (mvn test) from jenkins (windows) I see only the console output. I don't see the real browsers getting opened . How can I configure jenkins so that I can see the browsers running the test?
  这个问题今天终于解决了:
  1,对于selenium testing的GUI或者是browser不能看到,visible。但是可以看到的是在后台这个浏览器已经启动了,它实际上是后台运行的。
  这个原因就是windows设置的服务安全问题,在slave机器上运行测试时候,千万不要把其中的Jenkins-slave设置为windows的服务,而是转到前台运行,意思就是,在slave机器上的JNLP不能以服务启动,只能是如下的运行方式:

  这里注意了,千万不要点击“File”设置为服务启动,如果设置了后,即使你勾选了这个服务中的“Log on” Tab中的check "interact with desktop" , the desktop that is being referred to is invisble .,
  it works after running the agent using JNLP
  参考一:http://stackoverflow.com/questions/13639358/integration-of-selenium-webdriver-with-hudson-unable-to-open-the-browser
  Hi All, Just to update: this problem is solved. below are the details: Put Internet driver in path Run Browser Hub for remote exectution java -Dwebdriver.server.session.timeout=0 -jar selenium-server-standalone-2.25.0.jar -role hub java -Dwebdriver.server.session.timeout=0 -jar selenium-server-standalone-2.25.0.jar -role node -hublocalhost:4444/grid/register Refer following links: code.google.com/p/selenium/wiki/Grid2code.google.com/p/selenium/wiki/RemoteWebDriver code.google.com/p/selenium/wiki/WebDriverJs
  参考二:https://gist.github.com/djangofan/5174433(已经写好了slave机器的配置信息)
  hub设置脚本:
  

  

@ECHO off  
SETLOCAL ENABLEDELAYEDEXPANSION
  
TITLE WebDriver Grid Hub on 4444
  

  
ECHO *********************************************
  
ECHO *
  
ECHO * WebDriver grid Hub instance.
  
ECHO *
  
ECHO *  http://localhost:4444/grid/console
  
ECHO *
  
ECHO *********************************************
  
ECHO.
  

  
SET JAR=selenium-server-standalone-2.31.0.jar
  
SET "WGET=C:\Program Files (x86)\GnuWin32\bin\wget.exe"
  

  
IF NOT DEFINED JAVA_HOME (
  
ECHO You must define a JAVA_HOME environment variable before you run this script.
  
GOTO :ERROR
  
)
  
SET "PATH=%JAVA_HOME%\bin;%PATH%"
  

  
IF NOT EXIST %JAR% (
  
ECHO Selenium standalone server .jar is missing.
  
IF EXIST "%WGET%" (
  
ECHO Hit any key to download Selenium standalone .jar file.
  
PAUSE >nul
  
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%JAR%
  
) ELSE (
  
ECHO Wget.exe is missing. Install GNU Utils.
  
GOTO :ERROR
  
)
  
)
  
ECHO.
  

  
java.exe -jar %JAR% -role hub -hubConfig hubConfig.json -debug
  
IF NOT %ERRORLEVEL%==0 GOTO :ERROR
  

  
GOTO :END
  
:ERROR
  
ECHO There may have been an error.  Try running the script again.
  
pause
  
:END
  

  grid node设置脚本:
  

  

@ECHO off  
SETLOCAL ENABLEDELAYEDEXPANSION

  
SET>  
TITLE %TITLETEXT%
  

  
SET CHROMEDRIVERZIP=chromedriver_win_26.0.1383.0.zip
  
SET CHROMEDRIVER=chromedriver.exe
  
SET JAR=selenium-server-standalone-2.31.0.jar
  
SET IEDRIVERZIP=IEDriverServer_Win32_2.31.0.zip
  
SET IEDRIVER=IEDriverServer.exe
  
SET "WGET=C:\Program Files (x86)\GnuWin32\bin\wget.exe"
  

  
ECHO *********************************************
  
ECHO *
  
ECHO * WebDriver Grid Node
  
ECHO * It requires that a WebDriver JSON Hub is already running, usually on port 4444.
  
ECHO * You can run more than one of these if each has its own JSON config file.
  
ECHO *
  
ECHO *********************************************
  
ECHO.
  

  
IF NOT DEFINED JAVA_HOME (
  
ECHO You must define a JAVA_HOME environment variable before you run this script.
  
GOTO :ERROR
  
)
  
SET "PATH=.;%JAVA_HOME%\bin;%PATH%"
  

  
IF NOT EXIST %JAR% (
  
IF EXIST "%WGET%" (
  
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%JAR%
  
) ELSE (
  
ECHO Wget.exe is missing. Install GNU utils. & GOTO :ERROR
  
)
  
)
  

  
IF NOT EXIST %IEDRIVER% (
  
IF EXIST "%WGET%" (
  
"%WGET%" --dot-style=binary http://selenium.googlecode.com/files/%IEDRIVERZIP%
  
jar.exe xvf %IEDRIVERZIP%
  
DEL /Q %IEDRIVERZIP%
  
) ELSE (
  
ECHO Wget.exe is missing. & GOTO :ERROR
  
)
  
)
  

  
IF NOT EXIST %CHROMEDRIVER% (
  
IF EXIST "%WGET%" (
  
"%WGET%" --dot-style=binary --no-check-certificate https://chromedriver.googlecode.com/files/%CHROMEDRIVERZIP%
  
jar.exe xvf %CHROMEDRIVERZIP%
  
DEL /Q %CHROMEDRIVERZIP%
  
) ELSE (
  
ECHO Wget.exe is missing. & GOTO :ERROR
  
)
  
)
  

  
ECHO.
  
ECHO ======================
  
ECHO Grid Hub status : & netstat -an | FIND "4444"
  
ECHO ======================
  
ECHO.
  

  
TITLE %TITLETEXT%
  
java.exe -jar %JAR% -role node -nodeConfig node1Config.json -Dwebdriver.chrome.driver=%CHROMEDRIVER%
  

  
GOTO :END
  
:ERROR
  
pause
  
:END
  

  

  Stop Hub 节点的脚本:
  https://groups.google.com/forum/#!topic/selenium-users/_8A3q_ekw0g
  尝试这下面的另外两种方法:
  http://localhost:4444/selenium-server/driver?cmd=getLogMessages (Error 500 java.lang.NullPointerException)
  http://localhost:4444/lifecycle-manager?action=shutdown (Does nothing)

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-432731-1-1.html 上篇帖子: 配置Jenkins的slave节点的详细步骤适合windows等其他平台(转) 下篇帖子: Jenkins配置备份恢复插件ThinBackup
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表