One suite setup, parallel testlevelsplit

Can I somehow parallel test cases within a suite? I start a datadriven suite with testlevelsplit. For each test case Suite Setup and Suite Teardown are executed. Can I somehow use one Suite Setup for all test cases?

Yes. https://pabot.org/PabotLib.html#execution

thank you! do you know, if i can share a browser instance among parallel test cases?

Yes with:
Library pabot.SharedLibrary [library]

Wrap a library import with pabot.SharedLibrary to automatically make it a remote library when running with pabot. When running with robot, this will produce a normal library. Library instance will be shared with all executions. Scope of the library is global from pabot execution start to the end.

Hm… I did that, but using SharedLibrary with SeleniumLibrary produced an error ‘no browser is open’. Let me check the original stack trace.

I am running

  • python 3.8
  • pabot 1.2.1
  • seleniumlibrary 4.4.0

The robot file simply states:

*** Settings ***
Library    pabot.SharedLibrary    SeleniumLibrary

Stacktrace when starting with robot :

~$ robot -d output tasks/pabot_challenge_input_forms.robot

[ ERROR ] Error in file '/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/tasks/pabot_challenge_input_forms.robot' on line 3: Initializing test library 'pabot.SharedLibrary' with arguments [ RPA.Browser ] failed: No browser is open.
Traceback (most recent call last):
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/pabot/SharedLibrary.py", line 23, in __init__
    self._lib = RemoteLibraryFactory(TestLibrary(name).get_instance())
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 259, in RemoteLibraryFactory
    return DynamicRemoteLibrary(library, get_keyword_names, run_keyword)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 362, in __init__
    HybridRemoteLibrary.__init__(self, library, get_keyword_names)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 355, in __init__
    StaticRemoteLibrary.__init__(self, library)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 280, in __init__
    self._names, self._robot_name_index = self._get_keyword_names(library)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 285, in _get_keyword_names
    for name, kw in inspect.getmembers(library):
  File "/usr/lib/python3.8/inspect.py", line 350, in getmembers
    value = getattr(object, key)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/SeleniumLibrary/__init__.py", line 548, in driver
    raise NoOpenBrowser('No browser is open.')
[ ERROR ] Error in file '/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/resources/challenge_pabot.resource' on line 2: Initializing test library 'pabot.SharedLibrary' with arguments [ SeleniumLibrary ] failed: No browser is open.
Traceback (most recent call last):
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/pabot/SharedLibrary.py", line 23, in __init__
    self._lib = RemoteLibraryFactory(TestLibrary(name).get_instance())
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 259, in RemoteLibraryFactory
    return DynamicRemoteLibrary(library, get_keyword_names, run_keyword)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 362, in __init__
    HybridRemoteLibrary.__init__(self, library, get_keyword_names)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 355, in __init__
    StaticRemoteLibrary.__init__(self, library)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 280, in __init__
    self._names, self._robot_name_index = self._get_keyword_names(library)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/robotremoteserver.py", line 285, in _get_keyword_names
    for name, kw in inspect.getmembers(library):
  File "/usr/lib/python3.8/inspect.py", line 350, in getmembers
    value = getattr(object, key)
  File "/home/daedalus/PycharmProjects/rpa-challenge/rpa-challenge/venv/lib/python3.8/site-packages/SeleniumLibrary/__init__.py", line 548, in driver
    raise NoOpenBrowser('No browser is open.')

Looks pretty familiar, there have been similar complaints also before. Last time I looked Python remote server, it didn’t obey the dynamic library API fully. Although I am not totally sure are the remote library API and dynamic library API, Python remote server does not do keyword discover as the dynamic library API defines.

Seems that this is a known issue but no fix yet: https://github.com/robotframework/PythonRemoteServer/issues/55

1 Like

With pabot 1.8.0 now SeleniumLibrary as a SharedLibrary works.

1 Like

You rock! Now I just need datadriver supporting test split again, but that’s another issue.

Great job!

(post deleted by author)

Hi @mkorpela,
I want to use my init.robot before executing all parallel test cases but I have this error :
pabot --pabotlib --argumentfile1 arguments.txt --outputdir Results pabot_example*.robot


Suite ‘Init’ contains no tests or tasks.
Stopping PabotLib process
Robot Framework remote server at 127.0.0.1:8270 started.
Robot Framework remote server at 127.0.0.1:8270 stopped.
PabotLib process stopped
Total testing: 0.0 seconds
Elapsed time: 1.25 seconds


But when I replace the init.robot by using the keyword “Run Setup Only Once” at every suite, All of them are started!!
My need is to launch a suite setup which will be executed before launching the suites in parallel…
any help please?