gpt4 book ai didi

linux - 如何在安装了 jenkins 的 Azure VM 实例中以 GUI 模式执行 selenium 测试

转载 作者:太空宇宙 更新时间:2023-11-04 10:10:17 24 4
gpt4 key购买 nike

我在 VM 上安装了 Jenkins,托管在 Linux 操作系统 Azure 中。我想通过 Jenkins 在该 VM 中执行 selenium 脚本。我能够在 headless 模式下执行测试。但这里的问题是我需要在 GUI 模式下运行测试。是否有任何解决方法可以在 GUI 模式下运行自动化脚本。以下是我尝试在 GUI 模式下运行的内容。

  1. 通过putty安装chrome浏览器并设置chrome二进制路径。
  2. 尝试通过 xrdp 访问虚拟机。

但我无法在 GUI 模式下执行。任何帮助将不胜感激。

Chrome 版本:65

错误日志如下:

org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.13.0-36-generic x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.15 seconds Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'

最佳答案

我找到了这个 example在 Azure Pipelines 存储库上。在复制这段代码和文件 xvfb.init 后,我才设法让它工作。 .

steps:
- script: |
sudo cp .azure-pipelines/linux/xvfb.init /etc/init.d/xvfb
sudo chmod +x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
sudo service xvfb start
displayName: 'Start X Virtual Frame Buffer'

- script: |
export DISPLAY=:10
gulp test
displayName: 'Test'

关于linux - 如何在安装了 jenkins 的 Azure VM 实例中以 GUI 模式执行 selenium 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49492799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com