1

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.

Currently working on creating new jenkins project and adding my python script on that same project. Jenkin project will build at specific time. meanwhile python script will run.

My Python Code:

import webbrowser

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.

Sharathkumar KG
  • 63
  • 1
  • 2
  • 12
  • need more details.. In which machine did you test your python code ? Is it the same machine where Jenkins is hosted ? if the Jenkins is hosted in a different machine and if it is a server ( linux server or non-gui server ) you can not open a browser. – Sivaraj Velayutham Feb 17 '19 at 18:16
  • No, it’s same machine. – Sharathkumar KG Feb 18 '19 at 02:46

1 Answers1

0

u need headless browser plugin

in jenkins there plugin call Xvfb plugin

use of xvfb pugin

  1. Jenkins --> Plugin Manager --> avalible tab --> search xvfb and install
  2. Jenkins--> Global Tool Configuration

    • Xvfb installation under this
    • enter name
    • Directory in which to find Xvfb executable /usr/bin (its for 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.

Installing and Configuring xvfb here you can refer how to install xvfb in your pc

GHOST
  • 455
  • 6
  • 22