Issue trying to run robotframework script on Jenkins

Recently i’m facing an issue when try to run a task from Jenkins that simply run a .robot file.
I’ve been searching and trying different options from another colleagues that faced similar issues in StackOverFlow but i can’t achive to run the script correctly.

Please let me show you what i’m doing, my scripts and Jenkins setup so you can understand in a better way my problem.

I have this robot file:

*** Settings ***
Documentation   Basic Test
Library    SeleniumLibrary

*** Variables ***
#${result}    /opt/google/chrome/chrome
${Browser}    chrome
${options}    binary_location = '/opt/google/chrome/chrome'

*** Test Cases *** 
Abrir web Pangea
    Open Browser    url=https://www.google.com/    browser=${Browser}   options=${options}
    Close All Browsers

And i’m trying to run it as a Jenkin simple task with this simple build step:

robot --outputdir results --nostatusrc Test/basic_2.robot

But every time the Console Out show me the msg:

[Robot_QA_Executions] $ /bin/sh -xe /tmp/jenkins3290544249294601087.sh
+ robot --outputdir results --nostatusrc Test/basic_2.robot
==============================================================================
Basic 2 :: Basic Test                                                         
==============================================================================
Abrir web Pangea                                                      | FAIL |
WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
------------------------------------------------------------------------------
Basic 2 :: Basic Test                                                 | FAIL |
1 test, 0 passed, 1 failed
==============================================================================

To be sure of the Chrome path and this kind of things i also create this Python file:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

# Ruta del controlador de Chrome
webdriver.ChromeOptions.binary_location = '/opt/google/chrome/chrome'

# Opciones para el navegador
ChromeOptions = webdriver.ChromeOptions()
ChromeOptions.add_argument('--headless')

# Crea una instancia del navegador Chrome
driver = webdriver.Chrome(chrome_options=ChromeOptions)

# Navega a la pagina web de Google Espana
driver.get("https://www.google.es")
print("google abierto")
time.sleep(2)
driver.get("https://pangea.es/")
print("pangea abierto")

# Cierra el navegador
time.sleep(10)
driver.quit()
print("fin del test")

And after run, also from jenkin task with the build Step:

#!/usr/bin/env python3	./Test/ejemplo_Python_2.py

The Python Script works as expected.

Please can you help me to solve this issue? i tried with different optiones like “options”,“binary_location”, “executable_path” etc… with no success. :frowning:

I also double-check that i have installed:

$ /opt/google/chrome/chrome --version
Google Chrome 110.0.5481.177

$ chromedriver --veresion
Starting ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}) on port 9515

pip (9.0.3)
Pygments (2.14.0)
robotframework (6.0.2)
robotframework-datadriver (1.6.1)
robotframework-pythonlibcore (3.0.0)
robotframework-seleniumlibrary (6.0.0)
selenium (3.141.0)
setuptools (39.2.0)
urllib3 (1.26.14)

I would like to add more details to my issue.
If i try with

Create Webdriver    Chrome    executable_path=/usr/local/bin/chromedriver 
Go To    https://www.google.com

instead OpenBrowser. Jenkins return the error msg:

WebDriverException: Message: Service /opt/google/chrome/chrome unexpectedly exited. Status code was: 1

I expect to be able to run *.robot files from a Jenkins task (My Jenkins is over a AWS Linux machine) and the repositoty it’s on GitLab.

Hi Pablo,

Here’s the good news, I suspect your issue has nothing to do with Jenkins, and everything to with chrome, chromedriver and seleniumlibrary

This pretty much proves that Jenkins ran robot framework and Jenkins got the correct response from the ran robot framework test (the test failed)

Most commonly when I see this error:

It’s because chrome has auto-updated itself and you haven’t updates the chrome WebDriver, I see you did your best to ensure the versions the same :+1: but you might have been unlucky and got caught out on release day?

Monday, March 27, 2023
The Stable channel has been updated to 111.0.5563.147 for Mac and Linux and 111.0.5563.146/.147 for Windows

If you’re sure that chrome didn’t auto-update itself, you might have been unlucky with your chrome WebDriver version, seems from the release notes there were issues with Chromedriver version 110.0.5481.77:

ChromeDriver 112.0.5615.28
Supports Chrome version 112

  • Resolved issue 4357: Chromedriver version 110.0.5481.77 session issue with --headless and --user-data-dir options. [Pri-1]

I’ve also had issues in the past with ChromeDriver being less than Chrome even in the subminor version, in your case you are 77 vs 177, and 77 is the latest version in the 110.0.5481 range so it “should” work but not always

ChromeDriver 110.0.5481.77
Chrome 110.0.5481.177

I’ll suggest you try again with chrome/chromedriver 111.0.5563.x before wasting too much time on anything else

I’ve also had that error error: Chrome failed to start: exited abnormally. when I had a buggy version of chrome that was actually crashing on launch or when chromedriver crashed on launch (not for a long time though)

Hopefully some of this is helpful,

Dave.

Hi @damies13
Thanks for your time and for your support. I think that the problem was related mainly with the updates (as you told me). Right know all it’s working for me but i also did some changes in my script in order to be able to run it without issues.
I’ll let here the code that make my script works but i’m so convinced that updates were also there… (just in case other colleague could have the same issue trying to setup the chrome options)

First way:
*** Settings ***
Documentation test basico
Library SeleniumLibrary

*** Variables ***
${chrome_options} add_argument(“–headless”); add_argument(“no-sandbox”)

*** Test Cases ***
Abrir web Google
Open Browser https://google.es chrome options=${chrome_options}

Second way:
*** Settings ***
Documentation Basic Test
Library SeleniumLibrary

*** Variables ***
${Browser} chrome
${driver_path} /usr/bin/chromedriver
${chrome_options} add_argument(“–headless”); add_argument(“no-sandbox”)

*** Test Cases ***
Abrir web Google
Open Browser url=https://google.es/ browser=${Browser} options=${chrome_options} #executable_path=${driver_path}

Best regards!

Hi Pablo,

This is one of the reasons some people use Browser Library instead now. Browser Library seems to prevent the browsers from auto-updating so they can have the right driver for the browser version.

Another option that has worked for me is using installing webdrivermanager and then run webdrivermanager chrome before I run robot with my test (or even in a suite startup before opening the browser) this way if chrome auto-updated in the previous test then your webdriver gets updated to the version you need as well.

Dave.

Thanks for the tips @damies13
Will try the webdrivermanager option so maybe this will help to prevent future issues with chrome driver version missmatch.
When you talk about " then run webdrivermanager chrome before I run robot with my test" you mean that you build a python file and run this file before run .robot scripts? or is there any keyword that i can use?.

Thanks in advance!

1 Like

Hi Pablo,

It could be a python file, it doesn’t have to be. webdrivermanager can be run from the command line so it could be a simple shell script (.sh or .bat depending on your OS) or it could be simply a command you add to your Suite setup using Run or Run Process.

Dave.

Oh! understood.

So you mean something like:

*** Settings ***
Library    Process

*** Test Cases ***
Example Test
    Run Process    webdrivermanager    chrome

or like that if i would like to check if the process goes OK or not:

*** Settings ***
Library    Process

*** Test Cases ***
Example Test
    ${result}    Run Process And Log Output    webdrivermanager    chrome
    Log    ${result.stdout}
    Should Not Contain    ${result.stderr}    ERROR    
    Should Be Equal As Strings    ${result.returncode}    0    

Or can i even include it as a TestSuite Setup, right?

Best regards

1 Like

Hi Pablo,

Yes, I would put it in TestSuite Setup as it’s not really a test of you application but rather something you need to support the test.

Just move Example Test as is to keywords and call the keyword as your Test Suite Setup, probably also give it a more meaningful name like Webdriver Update

All that will happen most of the time is you get a message that the webdriver is up to date, but occasionally you’ll see it update the webdriver, then you’ll know it saved you.

Dave.

i have robot script including selenium2 library. Running the script on Firefox browser.
python version is 2.7.18
geckodriver version 0.30.0
Mozilla Firefox 112.0.2
the script worked with same config in one machine. this script fail in another machine with same config with message WebDriverException: Message: Process unexpectedly closed with status 1

And i’m trying to run it as a Jenkin simple task with this simple build step:

robot  Demo1.robot

But every time the Console Out show me the msg:

C:\Users\Rushi Reddy\Desktop\RobotframeworkMain>robot *.robot 
'robot' is not recognized as an internal or external command,
operable program or batch file.

Hi @Rushikesh
Looks like you have to install robot library in your jenkins machine.

I have isntalled robot framework plugins in jenkins still its showing error can you explain it little more…Please

The error message it’s telling you that Jenkins do not understand the command “robot demo1.robot” so the problem could be related with the robotframework installation.
Did you install Python and robotframework in your jenkins server? If yes check that it’s in the path so you could use the command.

I’m not a Pro with robot and jenkins, sorry

1 Like

i ahve installed plugin which is required for robot framework dont know why its showing an error

Jenkins RF plugin does not install robot itself into your jenkins environment. It just adds a code into jenkins that lets jenkins read the test report and log files and publish those in format that can be integrated into Jenkins UI.

As @coopernico46 said, you need to install robot and its dependencies separately into each jenkins slave / master node where you intend to run robot.

2 Likes

Use python -m robot Demo1.robot while Executing Windows batch command