简体   繁体   English

浏览器未使用python脚本通过Jenkins启动

[英]Browsers not launching through Jenkins using python script

Python script will help us to open new browser, When we run the script via any ide(cmd prompt) new browser will open but when the same script run via jenkins project it will not open browser. Python脚本将帮助我们打开新的浏览器,当我们通过任何ide(cmd提示符)运行脚本时,将打开新的浏览器,但是当通过jenkins项目运行相同的脚本时,它将不会打开浏览器。

Currently working on creating new jenkins project and adding my python script on that same project. 目前正在创建新的jenkins项目并在同一项目上添加我的python脚本。 Jenkin project will build at specific time. Jenkin项目将在特定时间构建。 meanwhile python script will run. 同时python脚本将运行。

My Python Code: 我的Python代码:

import webbrowser 导入网络浏览器

webbrowser.open(' https://www.google.com/ ', new = 2) webbrowser.open(' https://www.google.com/',new = 2)

Can any one help me out to open a browser when i run the python script via jenkin's project. 当我通过jenkin的项目运行python脚本时,谁能帮助我打开浏览器。

u need headless browser plugin 你需要无头的浏览器插件

in jenkins there plugin call Xvfb plugin 在詹金斯那里插件调用Xvfb插件

use of xvfb pugin xvfb pugin的使用

  1. Jenkins --> Plugin Manager --> avalible tab --> search xvfb and install Jenkins->插件管理器->可用选项卡->搜索xvfb并安装
  2. Jenkins--> Global Tool Configuration Jenkins->全局工具配置

    • Xvfb installation under this Xvfb下的安装
    • enter name 输入名字
    • Directory in which to find Xvfb executable /usr/bin (its for ubuntu) 在其中找到Xvfb可执行文件/ usr / bin的目录(对于ubuntu)

      1. click save 点击保存

then go to your jobs ==> Configure --> under Build Environment enable tick here Start Xvfb before the build, and shut it down after. 然后转到您的工作==>配置->在“构建环境”下,启用此处打勾在Start Xvfb before the build, and shut it down after.

Installing and Configuring xvfb here you can refer how to install xvfb in your pc 在这里安装和配置xvfb ,您可以参考如何在PC中安装xvfb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM