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 faced some issues when I wanted to run some functional (GUI) tests of a NetBeans platform app using a Jenkins job running on Windows. Since the Jenkins process could not access the windows display all the GUI tests were failing. On a linux box this issue is addressed by using X display such Xvnc (available as a Jenkins plugin), but of course I cannot use X display on windows!

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. Although I didn’t use a servlet container such as Tomcat the solution applies to my situation as well.

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

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

 

grid node设置脚本:

@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
SET TITLETEXT=WebDriver Grid Node
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

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

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)

selenium2 run in Jenkins GUI testing not visible or browser not open but run in background浏览器后台运行不可见的更多相关文章

  1. 【Selenium2】【Jenkins】

    1. 下载Tomcat ,Windows7 环境,http://tomcat.apache.org/  我下载的是版本8 2. 下载Jenkins,Windows7 环境,http://jenkins ...

  2. 怎么让jenkins保持后台运行

    今天在腾讯云直接使用命令启动jenkins,java -jar jenkins.war --httpPort=8080,这样启动关掉shell窗口或退回shell窗口,进程就会结束,需要重新 启动,非 ...

  3. 25+ Useful Selenium Web driver Code Snippets For GUI Testing Automation

    本文总结了使用Selenium Web driver 做页面自动化测试的一些 tips, tricks, snippets. 1. Chrome Driver 如何安装 extensions 两种方式 ...

  4. The Linux Mint 18.1:Eclipse Run The C++ And Python ConfigorationWhen You achieve above step,you can run the c++ and python! (Next OTL ,PYOTL is Project That Write By Ruimin Shen(ability man) )

    # Copyright (c) 2016, 付刘伟 (Liuwei Fu)# All rights reserved.# 转载请注明出处 1.Install The Eclipse,g++ Use T ...

  5. Tomcat中catalina run后台运行脚本

    编写启动脚本start.sh,将其放在/srv/aubapp/bin/下 #!/bin/sh #设置web应用程序目录 export CATALINA_BASE="/srv/aubapp&q ...

  6. Vue 项目: npm run dev b报错 “'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序 或批处理文件。”

    前提: 电脑已经安装了nodeJS和npm,  项目是直接下载的zip包. 报错步骤为1:cd /d 目录: 2. npm ren dev  -------> 报错如下: > webpac ...

  7. 既然 start() 方法会调用 run() 方法,为什么我们调用 start() 方法,而不直接调用 run() 方法?

    当你调用 start() 方法时,它会新建一个线程然后执行 run() 方法中的代码.如果直接调用 run() 方法,并不会创建新线程,方法中的代码会在当前调用者的线程中执行

  8. 解决 npm run dev b报错 “'webpack-dev-server' 不是内部或外部命令,也不是可运行的程序 或批处理文件。”

    摘自:https://www.cnblogs.com/laraLee/p/9174383.html 前提: 电脑已经安装了nodeJS和npm,  项目是直接下载的zip包. 在项目目录下运行“npm ...

  9. npm run start 后台运行

    yum provides */nohup nohup npm start & 原程序的的标准输出被自动改向到当前目录下的nohup.out文件,起到了log的作用. 停止程序   ps -ef ...

随机推荐

  1. [Swift]LeetCode955. 删列造序 II | Delete Columns to Make Sorted II

    We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose an ...

  2. .NET Core实战项目之CMS 第五章 入门篇-Dapper的快速入门看这篇就够了

    写在前面 上篇文章我们讲了如在在实际项目开发中使用Git来进行代码的版本控制,当然介绍的都是比较常用的功能.今天我再带着大家一起熟悉下一个ORM框架Dapper,实例代码的演示编写完成后我会通过Git ...

  3. 利用Python爬去囧网福利(多线程、urllib、request)

    import os; import urllib.request; import re; import threading;# 多线程 from urllib.error import URLErro ...

  4. Spring Boot Cache配置 序列化成JSON字符串

    当我们使用@Cacheable注解的时候会将返回的对象缓存起来,我们会发现默认缓存的值是二进制的,不方便查看,为此我们自定义序列化配置,改成JSON格式的 配置如下: pom.xml <?xml ...

  5. redis 系列15 数据对象的(类型检查,内存回收,对象共享)和数据库切换

    一.  概述 对于前面的五章中,已清楚了数据对象的类型以及命令实现,其实还有一种数据对象为HyperLogLog,以后需要用到再了解.下面再了解类型检查,内存回收,对象共享,对象的空转时长. 1.1 ...

  6. Spring RestTemplate中几种常见的请求方式

    https://github.com/lenve/SimpleSpringCloud/tree/master/RestTemplate在Spring Cloud中服务的发现与消费一文中,当我们从服务消 ...

  7. SB!SB!SB!

    Topic Link http://ctf5.shiyanbar.com/stega/ste.png SB!SB!SB! 其实很简单,可别真的变成 SB! 1)根据链接提示,直接用stegsolve ...

  8. leetcode — gas-station

    /** * Source : https://oj.leetcode.com/problems/gas-station/ * * There are N gas stations along a ci ...

  9. 在centos7中python3的安装注意

    ---恢复内容开始--- 云主机的python是2.7有些不方便,故要更换3,看到官网有3.6的包,就下载了. wget https://www.python.org/ftp/python/3.6.3 ...

  10. jmeter 分布式压测(Linux)

    之前一篇博文写的是如何在Linux上使用jmeter压测,这篇介绍下Linux上jmeter的分布式压测. 和windows上的分布式类似,需要配置agent节点和控制机 一.Agent节点配置 1. ...