kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
412 stars 52 forks source link

Exception websockets.exceptions.InvalidMessage: did not receive a valid HTTP response #198

Closed FreeM1ne closed 3 months ago

FreeM1ne commented 3 months ago

It's just that this error started appearing out of nowhere

Edit: if i remove await driver.switch_to.default_content() all work

Traceback (most recent call last):
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\http.py", line 120, in read_response
    status_line = await read_line(stream)
                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\http.py", line 200, in read_line
    raise EOFError("line without CRLF")
EOFError: line without CRLF

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\client.py", line 138, in read_http_response
    status_code, reason, headers = await read_response(self.reader)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\http.py", line 122, in read_response
    raise EOFError("connection closed while reading HTTP status line") from exc
EOFError: connection closed while reading HTTP status line

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\oreha\PycharmProjects\main_project\checkers\work_webgmx_just_valid\frames.py", line 41, in <module>
    asyncio.run(sss_rang())
  File "C:\Users\oreha\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\checkers\work_webgmx_just_valid\frames.py", line 31, in sss_rang
    await driver.save_screenshot("sss1.png")
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\webdriver.py", line 1094, in save_screenshot
    return await self.get_screenshot_as_file(filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\webdriver.py", line 1090, in get_screenshot_as_file
    return await self.current_target.get_screenshot_as_file(filename=filename)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\types\target.py", line 796, in get_screenshot_as_file
    png = await self.get_screenshot_as_png()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\types\target.py", line 831, in get_screenshot_as_png
    base_64 = await self.get_screenshot_as_base64()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\types\target.py", line 843, in get_screenshot_as_base64
    res = await self.execute_cdp_cmd("Page.captureScreenshot", {"format": "png"}, timeout=30)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\types\target.py", line 934, in execute_cdp_cmd
    await self._init()
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\selenium_driverless\types\target.py", line 137, in _init
    self._socket = await SingleCDPSocket(websock_url=f'ws://{self._host}/devtools/page/{self._id}',
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\cdp_socket\socket.py", line 46, in start_session
    self._ws: websockets.WebSocketClientProtocol = await websockets.connect(uri=self._url,
                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\client.py", line 659, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\client.py", line 666, in __await_impl__
    await protocol.handshake(
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\client.py", line 326, in handshake
    status_code, response_headers = await self.read_http_response()
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\oreha\PycharmProjects\main_project\.venv\Lib\site-packages\websockets\legacy\client.py", line 144, in read_http_response
    raise InvalidMessage("did not receive a valid HTTP response") from exc
websockets.exceptions.InvalidMessage: did not receive a valid HTTP response
FreeM1ne commented 3 months ago

switch frame not work

kaliiiiiiiiii commented 3 months ago

@FreeM1ne Not a bug in my code//no way to recover from. That's Chrome sending smth invalid.

kaliiiiiiiiii commented 3 months ago

@FreeM1ne You open a lot of issues which I have to close as not planned. This is my last warning. PLEASE mind

If that doesn't improve, I'll have to block you from interacting with this repository.