skip to Main Content

Hi please help me I’m having trouble getting a Python script to work with Firefox and Selenium
I ran the command with pytest and this comes out please help me
I use VPS Linux Ubuntu to start this script

 pytest /usr/local/bin/ciaobot/ciao.py --indirizzo "https://www.test.it" --profilo "ciao1"
========================================================== test session starts ==========================================================
platform linux -- Python 3.10.12, pytest-8.0.2, pluggy-1.4.0
rootdir: /usr/local/bin/ciaobot
plugins: devtools-0.12.2, anyio-4.3.0
collected 1 item

../usr/local/bin/ciao/ciao.py F                                                                                              [100%]

=============================================================== FAILURES ================================================================
______________________________________________________________ test_fbpost ______________________________________________________________

params = {'filelista': None, 'gruppo': None, 'indirizzo': 'https://www.test.it', 'messaggio': None, ...}

    def test_fbpost(params):
      profile_path = '/root/.mozilla/firefox-esr/' + params['profilo']
      options = Options()
      options.add_argument('-profile')
      options.add_argument(profile_path)
      options.add_argument("--width=1665")
      options.add_argument("--height=1720")
      options.set_preference('permissions.default.image', 2)
      options.set_preference('layout.css.devPixelsPerPx', '0.6')

      service = Service('/usr/local/bin/geckodriver', log_path='/dev/null')
>     driver = Firefox(service=service, options=options)

/usr/local/bin/ciaobot/ciao.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/firefox/webdriver.py:69: in __init__
    super().__init__(command_executor=executor, options=options)
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py:208: in __init__
    self.start_session(capabilities)
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py:292: in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/webdriver.py:347: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f1232ca8490>
response = {'status': 500, 'value': '{"value":{"error":"unknown error","message":"Process unexpectedly closed with status 1","stacktrace":""}}'}

    def check_response(self, response: Dict[str, Any]) -> None:
        """Checks that a JSON response from the WebDriver does not have an
        error.

        :Args:
         - response - The JSON response from the WebDriver server as a dictionary
           object.

        :Raises: If the response contains an error message.
        """
        status = response.get("status", None)
        if not status or status == ErrorCode.SUCCESS:
            return
        value = None
        message = response.get("message", "")
        screen: str = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get("value", None)
            if value_json and isinstance(value_json, str):
                import json

                try:
                    value = json.loads(value_json)
                    if len(value) == 1:
                        value = value["value"]
                    status = value.get("error", None)
                    if not status:
                        status = value.get("status", ErrorCode.UNKNOWN_ERROR)
                        message = value.get("value") or value.get("message")
                        if not isinstance(message, str):
                            value = message
                            message = message.get("message")
                    else:
                        message = value.get("message", None)
                except ValueError:
                    pass

        exception_class: Type[WebDriverException]
        e = ErrorCode()
        error_codes = [item for item in dir(e) if not item.startswith("__")]
        for error_code in error_codes:
            error_info = getattr(ErrorCode, error_code)
            if isinstance(error_info, list) and status in error_info:
                exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
                break
        else:
            exception_class = WebDriverException

        if not value:
            value = response["value"]
        if isinstance(value, str):
            raise exception_class(value)
        if message == "" and "message" in value:
            message = value["message"]

        screen = None  # type: ignore[assignment]
        if "screen" in value:
            screen = value["screen"]

        stacktrace = None
        st_value = value.get("stackTrace") or value.get("stacktrace")
        if st_value:
            if isinstance(st_value, str):
                stacktrace = st_value.split("n")
            else:
                stacktrace = []
                try:
                    for frame in st_value:
                        line = frame.get("lineNumber", "")
                        file = frame.get("fileName", "<anonymous>")
                        if line:
                            file = f"{file}:{line}"
                        meth = frame.get("methodName", "<anonymous>")
                        if "className" in frame:
                            meth = f"{frame['className']}.{meth}"
                        msg = "    at %s (%s)"
                        msg = msg % (meth, file)
                        stacktrace.append(msg)
                except TypeError:
                    pass
        if exception_class == UnexpectedAlertPresentException:
            alert_text = None
            if "data" in value:
                alert_text = value["data"].get("text")
            elif "alert" in value:
                alert_text = value["alert"].get("text")
            raise exception_class(message, screen, stacktrace, alert_text)  # type: ignore[call-arg]  # mypy is not smart enough here
>       raise exception_class(message, screen, stacktrace)
E       selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1

/usr/local/lib/python3.10/dist-packages/selenium/webdriver/remote/errorhandler.py:229: WebDriverException
======================================================== short test summary info ========================================================
FAILED ../usr/local/bin/ciaobot/ciao.py::test_fbpost - selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
========================================================== 1 failed in 10.21s ===========================================================

I need help please thank you

2

Answers


  1. Chosen as BEST ANSWER

    how do I help me? I can't solve it, I use ubuntu

    thank you for help

    How do I update better than I can't?


  2. Update your geckodriver and Firefox version and try again. hope this will work👍

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search