Jenkins:Selenium GUI 测试在 Windows 上不可见

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9618774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 09:20:22  来源:igfitidea点击:

Jenkins : Selenium GUI tests are not visible on Windows

windowsmavenseleniumjenkinswebdriver

提问by Rajesh

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?

当我从 jenkins (windows) 运行我的 selenium 测试 (mvn test) 时,我只看到控制台输出。我没有看到真正的浏览器被打开。如何配置 jenkins 以便我可以看到运行测试的浏览器?

采纳答案by Rajesh

I got the solution. I ran jenkins from command prompt as "java -jar jenkins.war" instead of the windows installer version. Now I can see my browser based tests being executed.

我得到了解决方案。我从命令提示符运行 jenkins 作为“java -jar jenkins.war”而不是 Windows 安装程序版本。现在我可以看到正在执行的基于浏览器的测试。

回答by Shessuky

I had the same problem, i got the solution after many attempts. This solution works ONLYon windows XP

我遇到了同样的问题,经过多次尝试,我得到了解决方案。此解决方案仅适用Windows XP

If you are using jenkins as a windows service you need to do the following :

如果您使用 jenkins 作为 Windows 服务,您需要执行以下操作:

1) In windows service select the service of jenkins

1)在windows服务中选择jenkins的服务

Opening Service.msc view

打开 Service.msc 视图

2) Open properties window of the service -> Logon-> enable the checkbox "Allow service to interact with desktop"

2)打开服务的属性窗口->登录->启用复选框“允许服务与桌面交互”

Jenkins properties

詹金斯属性

After then you should reboot the service jenkins

之后你应该重新启动服务 jenkins

Hope this help you :)

希望这对你有帮助:)

UPDATE:

更新

Actually, I'm working on a an automation tool using Selenium on Windows 10, I've installed Jenkins ver. 2.207 as windows application (EXE file), it's running as windows service and ALL drivers (Chrome, FireFox, IE) are visible during test executions WITHOUT performing a mere configuration on the System or Jenkins

实际上,我正在Windows 10上使用 Selenium 开发自动化工具,我已经安装了 Jenkins 版本。2.207 作为 windows 应用程序(EXE 文件),它作为 windows 服务运行,并且所有驱动程序(Chrome、FireFox、IE)在测试执行期间都是可见的,无需在系统或 Jenkins 上执行简单的配置

回答by malenkiy_scot

If you are already doing what @Sachin suggests in a comment (i.e. looking at the machine where Jenkins actually runs) and still do not see the browsers, then your problem may be the following:

如果您已经按照@Sachin 在评论中的建议(即查看 Jenkins 实际运行的机器)并且仍然没有看到浏览器,那么您的问题可能如下:

If you run Jenkins as a service in the background it won't open apps in the foreground. You may either try to run it not as a service in the foreground, or run it as a Local Systemaccount and check Allow the service to interact with desktopoption. In the latter case you may get into permission problems, though.

如果您在后台将 Jenkins 作为服务运行,它不会在前台打开应用程序。您可以尝试不将其作为前台服务运行,也可以将其作为本地系统帐户运行并选中允许服务与桌面交互选项。但是,在后一种情况下,您可能会遇到权限问题。

Update:To make sure this answer is understood properly by others: Jenkins Windows 'native' installation is not really native. It's a wrapper around Java that runs it as a service.

更新:为了确保其他人正确理解此答案:Jenkins Windows“本机”安装并不是真正的本机。它是 Java 的包装器,将其作为服务运行。

回答by Noam Manos

To interact with desktop GUI, you should launch slave agent via JNLP: https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-LaunchslaveagentviaJavaWebStart

要与桌面 GUI 交互,您应该通过 JNLP 启动从代理:https: //wiki.jenkins-ci.org/display/JENKINS/Distributed+builds#Distributedbuilds-LaunchslaveagentviaJavaWebStart

After adding the node in Jenkins (configured as Java Web Start launch), just make a startup batch script on the node machine:

在Jenkins中添加节点后(配置为Java Web Start启动),在节点机器上做一个启动批处理脚本即可:

java -jar slave.jar -jnlpUrl http://{Your Jenkins Server}:8080/computer/{Your Jenkins Node}/slave-agent.jnlp

(slave.jar can be downloaded from http://{Your Jenkins Server}:8080/jnlpJars/slave.jar)

(slave.jar 可以从 http://{Your Jenkins Server}:8080/jnlpJars/slave.jar 下载)

See more answers here: How to run GUI tests on a jenkins windows slave without remote desktop connection?

在此处查看更多答案: 如何在没有远程桌面连接的情况下在 jenkins windows slave 上运行 GUI 测试?

回答by Shessuky

In the case of Windows 7you should not install jenkins as windows application (because in this recent version, Microsoft decided to give services their own hidden desktop even you enable the functionality "interact with desktop" in jenkins service), you may have to deploy it from a war file as follows:

Windows 7的情况下,您不应该将 jenkins 安装为 Windows 应用程序(因为在这个最新版本中,即使您启用了 jenkins 服务中的“与桌面交互”功能,Microsoft 也决定为服务提供自己的隐藏桌面),您可能需要部署它来自一个War文件,如下所示:

1) Download jenkins.war from Jenkins official site

1) 从Jenkins 官网下载 jenkins.war

2) Deploy it by the command prompt : java -jar {directoryOfJenkinsFile}/jenkins.war

2)通过命令提示符部署它:java -jar {directoryOfJenkinsFile}/jenkins.war

3) Now you can access jenkins administration on http:// localhost:8080

3) 现在您可以在 http://localhost:8080 上访问 jenkins 管理

Hope that helps you !

希望能帮到你!

回答by user2792870

this is an issue for Jenkins. on Windows it is possible to access logon user's session (screen) under system account. to make the UI testing visible, Jenkins needs to bypass UAC (user access control) at background. this solution works for me with my own service running as system account.

这是詹金斯的一个问题。在 Windows 上,可以在系统帐户下访问登录用户的会话(屏幕)。为了使 UI 测试可见,Jenkins 需要在后台绕过 UAC(用户访问控制)。这个解决方案适用于我自己的服务作为系统帐户运行。

回答by Divya C

If jenkins installed by windows installer it is showing only Console out put only. To see browsers download jenkins.war file and run java -jar jenkins.war from command line. Go through this site: http://learnseleniumtesting.com/jenkins-and-continuous-test-execution/

如果 jenkins 由 windows 安装程序安装,它只显示控制台输出。要查看浏览器,请下载 jenkins.war 文件并从命令行运行 java -jar jenkins.war。通过这个网站:http: //learnseleniumtesting.com/jenkins-and-continuous-test-execution/

回答by Subash

If you have the following situation,

如果你有以下情况,

  1. You are able to login to the remote machine
  2. You don't see the Jenkins agent window
  3. This slave machine is accessed by many users then try the following,
  1. 您可以登录到远程机器
  2. 您看不到 Jenkins 代理窗口
  3. 这台从机被许多用户访问,然后尝试以下操作,

then try the following suggestion.

然后尝试以下建议。

  • Login to slave machine
  • Go to Task manager
  • Users
  • Logout all the users
  • Then login again.
  • 登录从机
  • 进入任务管理器
  • 用户
  • 注销所有用户
  • 然后再次登录。

This worked for me.

这对我有用。

回答by pablo casanovas

I also faced the same issue earlier in my local machine (Windows 10). My test was running perfectly from the NetBeans but when I moved to Jenkins it was only running in console mode. I was unable to view the UI.

我之前在本地机器(Windows 10)中也遇到过同样的问题。我的测试从 NetBeans 完美运行,但是当我转移到 Jenkins 时,它仅在控制台模式下运行。我无法查看用户界面。

So for that, you just need to make your local machine as a Jenkins slave by creating a new slave node in your Jenkins and select that node to execute the Jenkins job.

因此,为此,您只需要通过在您的 Jenkins 中创建一个新的从节点并选择该节点来执行 Jenkins 作业,将您的本地机器作为 Jenkins 从节点。