Hi Junior,
In order to run browser in headless mode in behave for selenium automation on Lambdatest, you can use the below code snippet:
pipline
{
withEnv(["LT_USERNAME=Your LambdaTest UserName",
"LT_ACCESS_KEY=Your LambdaTest Access Key",
"LT_TUNNEL=true"]){
echo env.LT_USERNAME
echo env.LT_ACCESS_KEY
stages{
stage('setup') {
// Get some code from a GitHub repository
try{
git 'https://github.com/LambdaTest/python-selenium-sample'
//Download Tunnel Binary
sh "wget https://s3.amazonaws.com/lambda-tunnel/LT_Linux.zip"
//Required if unzip is not installed
sh 'sudo apt-get install --no-act unzip'
sh 'unzip -o LT_Linux.zip'
//Starting Tunnel Process
sh "./LT -user ${env.LT_USERNAME} -key ${env.LT_ACCESS_KEY} &"
sh "rm -rf LT_Linux.zip"
}
catch (err){
echo err
}
}
stage('build') {
// Installing Dependencies
sh 'pip install -r requirements.txt'
}
stage('test') {
try{
sh 'python lambdatest.py'
}
catch (err){
echo err
}
}
stage('end') {
echo "Success"
}
}
}
}
Here’s the GitHub repo for the same : GitHub - Elmasekar/Python-selenium-jenkins: A sample repo to help you integrate Jenkins pipeline for Python-selenium on LambdaTest. Run your Python automation test scripts on Lambdatest.