Jenkins - AttributeError: 'NoneType' object has no attribute 'write' after upgrading Selenium2Library

I have a project in Jenkins where test scenarios are run with a Windows batch command: robot [arguments]
The project worked fine until I upgraded Selenium2Library with
pip install --upgrade robotframework-selenium2library
The scenarios run fine in a windows command prompt. When running it on Jenkins, I get the error AttributeError: 'NoneType' object has no attribute 'write'
No output.xml file is generate from the runs in Jenkins.
I have python 3.9.7 installed
I am kind lost here and don’t even know what other information I should provide.
Thank you for any insight!

Hi Pedro,

From the SeleniumLibrary introduction:

SeleniumLibrary is based on the old SeleniumLibrary that was forked to Selenium2Library and then later renamed back to SeleniumLibrary. See the Versions and History sections below for more information about different versions and the overall project history.

Selenium2Library is the old library so not an upgrade but a downgrade, I suggest you go back to SeleniumLibrary (the current version) and see if you still have an issue?



I’m also facing the same issue “AttributeError: ‘NoneType’ object has no attribute ‘write’” with Log keyword. I’m trying to log a message with “level=WARN” with “html=True” which will give background colour to the warning message. While running the test case from windows command prompt I’m not seeing the failure in the Log keyword(working as expected). But while executing the test cases from Jenkins Im seeing a failure in BuiltIn Log keyword. Please help me to understand the root cause

Attribute errors in Python are generally raised when you try to access or call an attribute that a particular object type doesn’t possess. It’s simply because there is no attribute with the name you called, for that Object. This means that you got the error when the “module” does not contain the method you are calling. But it is evident that the method is there, which leads to believe that may be the method was added by you in the source code after you had already imported the file (module). Or, some times packages get deprecated and they rename some functions. If that is true, then you may want to exit and reimport the module once again to be able to access the new method .

You can do it in another way to reimport the module with changes without having to exit the interpreter is to do the following:


If you are using python 3.2 or 3.3 you should:

import imp

If running Python 3.4 and up, do import importlib, then do:

import importlib

The importlib.reload() method reload a previously imported module. The argument must be a module object, so it must have been successfully imported before .