aerokube/selenoid

Starting selenoid video recording from python not working

dothebart opened this issue · 5 comments

I added the environment variable and the argument and the mountpoint to the selenoid docker container.

From within my python test code I'm invoking on the options object:

options.set_capability('enableVideo', True)

It seems that it does something to that regard:

docker logs selenoid -f
2024/01/12 12:25:00 [-] [INIT] [Loading configuration files...]
2024/01/12 12:25:00 [-] [INIT] [Loaded configuration from /etc/selenoid/browsers.json]
2024/01/12 12:25:00 [-] [INIT] [Video Dir: /opt/selenoid/video]
2024/01/12 12:25:00 [-] [INIT] [Your Docker API version is 1.43]
2024/01/12 12:25:00 [-] [INIT] [Timezone: UTC]
2024/01/12 12:25:00 [-] [INIT] [Listening on :4444]
2024/01/12 12:25:07 [-] [NEW_REQUEST] [unknown] [192.168.100.68]
2024/01/12 12:25:07 [-] [NEW_REQUEST_ACCEPTED] [unknown] [192.168.100.68]
2024/01/12 12:25:07 [0] [LOCATING_SERVICE] [chrome] []
2024/01/12 12:25:07 [-] [DEFAULT_VERSION] [Using default version: latest]
2024/01/12 12:25:07 [0] [USING_DOCKER] [chrome] [latest]
2024/01/12 12:25:07 [0] [CREATING_CONTAINER] [selenoid/chrome]
2024/01/12 12:25:07 [0] [STARTING_CONTAINER] [selenoid/chrome] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561]
2024/01/12 12:25:07 [0] [CONTAINER_STARTED] [selenoid/chrome] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561] [0.24s]
2024/01/12 12:25:07 [0] [CREATING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release]
2024/01/12 12:25:07 [0] [STARTING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release] [a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8]
2024/01/12 12:25:07 [0] [VIDEO_CONTAINER_STARTED] [selenoid/video-recorder:latest-release] [a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8] [0.30s]
2024/01/12 12:25:08 [0] [SERVICE_STARTED] [selenoid/chrome] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561] [0.10s]
2024/01/12 12:25:08 [0] [PROXY_TO] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561] [http://192.168.100.69:4444]
2024/01/12 12:25:08 [0] [SESSION_ATTEMPTED] [http://192.168.100.69:4444] [1]
2024/01/12 12:25:08 [0] [SESSION_FAILED] [http://192.168.100.69:4444] [400 Bad Request]
2024/01/12 12:25:08 [0] [STOPPING_VIDEO_CONTAINER] [a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8]
2024/01/12 12:25:10 [0] [REMOVING_CONTAINER] [a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8]
2024/01/12 12:25:10 [0] [FAILED_TO_REMOVE_CONTAINER] [a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8] [Error response from daemon: removal of container a76052de820407b940276b71ca874f1e960630b01ac5d2525333ef8071c107b8 is already in progress]
2024/01/12 12:25:10 [0] [REMOVING_CONTAINER] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561]
2024/01/12 12:25:10 [0] [CONTAINER_REMOVED] [3bea10e4cb693203b3538050bb4c4b13ab03d7d4115ac990ff8b8f5a5c9f3561]
2024/01/12 12:25:13 [-] [SHUTTING_DOWN] [5m0s]

however from then in the python code it ejects:

exiting load monitoring thread
Traceback (most recent call last):
  File "/home/release-test-automation/release_tester/full_download_test.py", line 157, in <module>
    sys.exit(main())
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/release-test-automation/release_tester/full_download_test.py", line 143, in main
    return package_test(
  File "/home/release-test-automation/release_tester/full_download_test.py", line 87, in package_test
    results.append(test_driver.run_test("all", "all", [dl_new.cfg.version], props))
  File "/home/release-test-automation/release_tester/test_driver.py", line 421, in run_test
    runner = make_runner(
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/allure_commons/_allure.py", line 172, in impl
    return func(*a, **kw)
  File "/home/release-test-automation/release_tester/arangodb/starter/deployments/__init__.py", line 122, in make_runner
    return Cluster(*args)
  File "/home/release-test-automation/release_tester/arangodb/starter/deployments/cluster.py", line 39, in __init__
    super().__init__(
  File "/home/release-test-automation/release_tester/arangodb/starter/deployments/runner.py", line 216, in __init__
    self.selenium = init_selenium(
  File "/home/release-test-automation/release_tester/arangodb/starter/deployments/selenium_deployments/__init__.py", line 67, in init
    driver = driver_func(**kwargs)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 209, in __init__
    self.start_session(capabilities)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 293, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 348, in execute
    self.error_handler.check_response(response)
  File "/usr/local/pyenv/versions/3.10.10/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: unrecognized capability: enableVideo
Stacktrace:
#0 0x55c1e50c7f83 <unknown>
#1 0x55c1e4d80cf7 <unknown>
#2 0x55c1e4da8e26 <unknown>
#3 0x55c1e4e03a64 <unknown>
#4 0x55c1e4e0339c <unknown>
#5 0x55c1e4e04f1c <unknown>
#6 0x55c1e4df9e53 <unknown>
#7 0x55c1e4dc1dd4 <unknown>
#8 0x55c1e4dc31de <unknown>
#9 0x55c1e508c531 <unknown>
#10 0x55c1e5090455 <unknown>
#11 0x55c1e5078f55 <unknown>
#12 0x55c1e50910ef <unknown>
#13 0x55c1e505c99f <unknown>
#14 0x55c1e50b5008 <unknown>
#15 0x55c1e50b51d7 <unknown>
#16 0x55c1e50c7124 <unknown>
#17 0x7f8f4af02ac3 <unknown>

any ideas what I'm not doing right here?

ok, it seems the example generation in
docker run --rm -d --name selenoid-ui --link selenoid -p 8090:8080 aerokube/selenoid-ui --selenoid-uri=http://selenoid:4444
tells to do this:

from selenium import webdriver
        
capabilities = {
    "browserName": "chrome",
    "browserVersion": "latest",
    "selenoid:options": {
        "enableVideo": False
    }
}

driver = webdriver.Remote(
    command_executor="http://172.17.0.3:4444/wd/hub",
    desired_capabilities=capabilities)

but that code results in:

Python 3.10.10 (main, Jan 11 2024, 10:33:12) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from selenium import webdriver
oid:options": {
        "enableVideo": False
    }
}

driver = webdriver.Remote(
    command_executor="http://172.17.0.3:4444/wd/hub",
    desired_capabilities=capabilities)
>>>         
>>> capabilities = {
...     "browserName": "chrome",
...     "browserVersion": "latest",
...     "selenoid:options": {
...         "enableVideo": False
...     }
... }
>>> 
>>> driver = webdriver.Remote(
...     command_executor="http://172.17.0.3:4444/wd/hub",
...     desired_capabilities=capabilities)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: WebDriver.__init__() got an unexpected keyword argument 'desired_capabilities'
>>> 

so something is not right here. Tried with python 3.10 (screen dump above) and 3.11.7 with latest selenium - similar results.

Ok, the magic spell to make it work seems to be nowadays:

options = webdriver.chrome.options.Options()
options.set_capability('selenoid:options', { 'enableVideo', True})

driver = webdriver.Remote(
    command_executor="http://172.17.0.3:4444/wd/hub",
    options=options)

Please adjust the example generating code and maybe add it somewhere better in the documentation.

We have plans to update UI code snippets.

thanks - please also refer to this in the documentation. since it took me quiet a while to figure out this container even existed.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.