0

Running this Django tests on chat app that has uses selenium

tests.py

from channels.testing import ChannelsLiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.wait import WebDriverWait

import os
print(os.environ['PATH'])

class ChatTests(ChannelsLiveServerTestCase):
    serve_static = True  # emulate StaticLiveServerTestCase

    @classmethod
    def setUpClass(cls):
        super().setUpClass()
        try:
            # NOTE: Requires "chromedriver" binary to be installed in $PATH
            cls.driver = webdriver.Firefox()
        except:
            super().tearDownClass()
            raise
  ...

when I run the test I get this error

(chatenv) muiruri_samuel@train:~/webapp/chatsys$ python manage.py test chat.tests
/home/muiruri_samuel/webapp/chatenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/local/games:/snap/bin
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
E
======================================================================
ERROR: setUpClass (chat.tests.ChatTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/muiruri_samuel/webapp/chatsys/chat/tests.py", line 17, in setUpClass
    cls.driver = webdriver.Firefox()
  File "/home/muiruri_samuel/webapp/chatenv/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py"
, line 170, in __init__
    keep_alive=True)
  File "/home/muiruri_samuel/webapp/chatenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",
 line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/muiruri_samuel/webapp/chatenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",
 line 245, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/muiruri_samuel/webapp/chatenv/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py",
 line 314, in execute
    self.error_handler.check_response(response)
  File "/home/muiruri_samuel/webapp/chatenv/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities


----------------------------------------------------------------------
Ran 0 tests in 1.012s

FAILED (errors=1)
Destroying test database for alias 'default'...

The results suggests that firefox isn't configured correctly. This is also running on a ubuntu vm server also.

I've checked to see how this also might be resolved from one post it recommends that some parameters need to be added to Firefox to make it work. From the post also it was configured for windows and the case doesn't seem to be as similar.

Community
  • 1
  • 1
Sam B.
  • 2,703
  • 8
  • 40
  • 78
  • Did you try the solutions [here](https://stackoverflow.com/questions/43713445/selenium-unable-to-find-a-matching-set-of-capabilities-despite-driver-being-in) ? -> update selenium and firefox – AntoineLB Jun 06 '18 at 10:28
  • worked, actually to note the server didn't have firefox installed once I installed it that fixed the issue. – Sam B. Jun 06 '18 at 10:32
  • Alright ! Good luck for your tests :) – AntoineLB Jun 06 '18 at 10:37

0 Answers0