HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
349 stars 52 forks source link

Unable to open URLs with chrome driver at all? #145

Closed AstroTheRabbit closed 2 years ago

AstroTheRabbit commented 2 years ago

I'm running macOS 10.15.7. Here's the command-line output/error:

Starting ChromeDriver 98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758@{#972}) on port 52847
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
2022-02-15 17:18.28 [info     ] request                        body={"capabilities": {"alwaysMatch": {"browserName": "chrome"}}} header={'Content-Type': 'application/json'} method=POST url=http://localhost:52847/session
2022-02-15 17:18.29 [info     ] response                       body={"capabilities": {"alwaysMatch": {"browserName": "chrome"}}} data={'value': {'capabilities': {'acceptInsecureCerts': False, 'browserName': 'chrome', 'browserVersion': '98.0.4758.102', 'chrome': {'chromedriverVersion': '98.0.4758.80 (7f0488e8ba0d8e019187c6325a16c29d9b7f4989-refs/branch-heads/4758@{#972})', 'userDataDir': '/var/folders/bn/hcgrb1n573110wpmq85zttgh0000gn/T/.com.google.Chrome.m7t4a0'}, 'goog:chromeOptions': {'debuggerAddress': 'localhost:52851'}, 'networkConnectionEnabled': False, 'pageLoadStrategy': 'normal', 'platformName': 'mac os x', 'proxy': {}, 'setWindowRect': True, 'strictFileInteractability': False, 'timeouts': {'implicit': 0, 'pageLoad': 300000, 'script': 30000}, 'unhandledPromptBehavior': 'dismiss and notify', 'webauthn:extension:credBlob': True, 'webauthn:extension:largeBlob': True, 'webauthn:virtualAuthenticators': True}, 'sessionId': '8207a190cba7a118c56f8a4a2f4f118c'}} method=POST response=<ClientResponse(http://localhost:52847/session) [200 OK]>
<CIMultiDictProxy('Content-Length': '798', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache')>
 url=http://localhost:52847/session
2022-02-15 17:18.29 [info     ] request                        body={"url": "www.google.com"} header={'Content-Type': 'application/json'} method=POST url=http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c/url
2022-02-15 17:18.29 [info     ] response                       body={"url": "www.google.com"} data={'value': {'error': 'invalid argument', 'message': 'invalid argument\n  (Session info: chrome=98.0.4758.102)', 'stacktrace': '0   chromedriver                        0x00000001064363c9 chromedriver + 5018569\n1   chromedriver                        0x00000001063c1333 chromedriver + 4539187\n2   chromedriver                        0x0000000105f9693f chromedriver + 170303\n3   chromedriver                        0x0000000105f82c36 chromedriver + 89142\n4   chromedriver                        0x0000000105f81924 chromedriver + 84260\n5   chromedriver                        0x0000000105f81a43 chromedriver + 84547\n6   chromedriver                        0x0000000105f9849e chromedriver + 177310\n7   chromedriver                        0x0000000105ffbde1 chromedriver + 585185\n8   chromedriver                        0x0000000105fe87e2 chromedriver + 505826\n9   chromedriver                        0x0000000105ffb604 chromedriver + 583172\n10  chromedriver                        0x0000000105fe86d3 chromedriver + 505555\n11  chromedriver                        0x0000000105fbe95e chromedriver + 334174\n12  chromedriver                        0x0000000105fbf935 chromedriver + 338229\n13  chromedriver                        0x00000001063f21ee chromedriver + 4739566\n14  chromedriver                        0x000000010640bf51 chromedriver + 4845393\n15  chromedriver                        0x0000000106411928 chromedriver + 4868392\n16  chromedriver                        0x000000010640ca7a chromedriver + 4848250\n17  chromedriver                        0x00000001063e6c31 chromedriver + 4693041\n18  chromedriver                        0x0000000106427978 chromedriver + 4958584\n19  chromedriver                        0x0000000106427b01 chromedriver + 4958977\n20  chromedriver                        0x000000010643d795 chromedriver + 5048213\n21  libsystem_pthread.dylib             0x00007fff692f1109 _pthread_start + 148\n22  libsystem_pthread.dylib             0x00007fff692ecb8b thread_start + 15\n'}} method=POST response=<ClientResponse(http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c/url) [400 Bad Request]>
<CIMultiDictProxy('Content-Length': '2011', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache')>
 url=http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c/url
2022-02-15 17:18.29 [error    ] error                          data={'error': 'invalid argument', 'message': 'invalid argument\n  (Session info: chrome=98.0.4758.102)', 'stacktrace': '0   chromedriver                        0x00000001064363c9 chromedriver + 5018569\n1   chromedriver                        0x00000001063c1333 chromedriver + 4539187\n2   chromedriver                        0x0000000105f9693f chromedriver + 170303\n3   chromedriver                        0x0000000105f82c36 chromedriver + 89142\n4   chromedriver                        0x0000000105f81924 chromedriver + 84260\n5   chromedriver                        0x0000000105f81a43 chromedriver + 84547\n6   chromedriver                        0x0000000105f9849e chromedriver + 177310\n7   chromedriver                        0x0000000105ffbde1 chromedriver + 585185\n8   chromedriver                        0x0000000105fe87e2 chromedriver + 505826\n9   chromedriver                        0x0000000105ffb604 chromedriver + 583172\n10  chromedriver                        0x0000000105fe86d3 chromedriver + 505555\n11  chromedriver                        0x0000000105fbe95e chromedriver + 334174\n12  chromedriver                        0x0000000105fbf935 chromedriver + 338229\n13  chromedriver                        0x00000001063f21ee chromedriver + 4739566\n14  chromedriver                        0x000000010640bf51 chromedriver + 4845393\n15  chromedriver                        0x0000000106411928 chromedriver + 4868392\n16  chromedriver                        0x000000010640ca7a chromedriver + 4848250\n17  chromedriver                        0x00000001063e6c31 chromedriver + 4693041\n18  chromedriver                        0x0000000106427978 chromedriver + 4958584\n19  chromedriver                        0x0000000106427b01 chromedriver + 4958977\n20  chromedriver                        0x000000010643d795 chromedriver + 5048213\n21  libsystem_pthread.dylib             0x00007fff692f1109 _pthread_start + 148\n22  libsystem_pthread.dylib             0x00007fff692ecb8b thread_start + 15\n'} message=invalid argument
  (Session info: chrome=98.0.4758.102) stacktrace=0   chromedriver                        0x00000001064363c9 chromedriver + 5018569
1   chromedriver                        0x00000001063c1333 chromedriver + 4539187
2   chromedriver                        0x0000000105f9693f chromedriver + 170303
3   chromedriver                        0x0000000105f82c36 chromedriver + 89142
4   chromedriver                        0x0000000105f81924 chromedriver + 84260
5   chromedriver                        0x0000000105f81a43 chromedriver + 84547
6   chromedriver                        0x0000000105f9849e chromedriver + 177310
7   chromedriver                        0x0000000105ffbde1 chromedriver + 585185
8   chromedriver                        0x0000000105fe87e2 chromedriver + 505826
9   chromedriver                        0x0000000105ffb604 chromedriver + 583172
10  chromedriver                        0x0000000105fe86d3 chromedriver + 505555
11  chromedriver                        0x0000000105fbe95e chromedriver + 334174
12  chromedriver                        0x0000000105fbf935 chromedriver + 338229
13  chromedriver                        0x00000001063f21ee chromedriver + 4739566
14  chromedriver                        0x000000010640bf51 chromedriver + 4845393
15  chromedriver                        0x0000000106411928 chromedriver + 4868392
16  chromedriver                        0x000000010640ca7a chromedriver + 4848250
17  chromedriver                        0x00000001063e6c31 chromedriver + 4693041
18  chromedriver                        0x0000000106427978 chromedriver + 4958584
19  chromedriver                        0x0000000106427b01 chromedriver + 4958977
20  chromedriver                        0x000000010643d795 chromedriver + 5048213
21  libsystem_pthread.dylib             0x00007fff692f1109 _pthread_start + 148
22  libsystem_pthread.dylib             0x00007fff692ecb8b thread_start + 15
 status=400 type=<class 'arsenic.errors.UnknownArsenicError'>
2022-02-15 17:18.29 [info     ] request                        body=None header=None method=DELETE url=http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c
2022-02-15 17:18.30 [info     ] response                       body=None data={'value': None} method=DELETE response=<ClientResponse(http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c) [200 OK]>
<CIMultiDictProxy('Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'Cache-Control': 'no-cache')>
 url=http://localhost:52847/session/8207a190cba7a118c56f8a4a2f4f118c
Traceback (most recent call last):
  File "/Users/home/Documents/Python Scripts/arsenicTest.py", line 14, in <module>
    asyncio.run(GoToGoogle())
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
    return future.result()
  File "/Users/home/Documents/Python Scripts/arsenicTest.py", line 11, in GoToGoogle
    await session.get("www.google.com")
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/session.py", line 152, in get
    await self._request(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/session.py", line 40, in _request
    status, data = await self.connection.request(
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/connection.py", line 55, in wrapper
    return await asyncio.get_event_loop().create_task(func(*args, **kwargs))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/connection.py", line 121, in request
    check_response_error(data=data, status=response.status)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/connection.py", line 72, in check_response_error
    errors.raise_exception(data, status)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/arsenic/errors.py", line 109, in raise_exception
    raise exception_class(message, screen, stacktrace)
arsenic.errors.UnknownArsenicError: ('invalid argument\n  (Session info: chrome=98.0.4758.102)', None, '0   chromedriver                        0x00000001064363c9 chromedriver + 5018569\n1   chromedriver                        0x00000001063c1333 chromedriver + 4539187\n2   chromedriver                        0x0000000105f9693f chromedriver + 170303\n3   chromedriver                        0x0000000105f82c36 chromedriver + 89142\n4   chromedriver                        0x0000000105f81924 chromedriver + 84260\n5   chromedriver                        0x0000000105f81a43 chromedriver + 84547\n6   chromedriver                        0x0000000105f9849e chromedriver + 177310\n7   chromedriver                        0x0000000105ffbde1 chromedriver + 585185\n8   chromedriver                        0x0000000105fe87e2 chromedriver + 505826\n9   chromedriver                        0x0000000105ffb604 chromedriver + 583172\n10  chromedriver                        0x0000000105fe86d3 chromedriver + 505555\n11  chromedriver                        0x0000000105fbe95e chromedriver + 334174\n12  chromedriver                        0x0000000105fbf935 chromedriver + 338229\n13  chromedriver                        0x00000001063f21ee chromedriver + 4739566\n14  chromedriver                        0x000000010640bf51 chromedriver + 4845393\n15  chromedriver                        0x0000000106411928 chromedriver + 4868392\n16  chromedriver                        0x000000010640ca7a chromedriver + 4848250\n17  chromedriver                        0x00000001063e6c31 chromedriver + 4693041\n18  chromedriver                        0x0000000106427978 chromedriver + 4958584\n19  chromedriver                        0x0000000106427b01 chromedriver + 4958977\n20  chromedriver                        0x000000010643d795 chromedriver + 5048213\n21  libsystem_pthread.dylib             0x00007fff692f1109 _pthread_start + 148\n22  libsystem_pthread.dylib             0x00007fff692ecb8b thread_start + 15\n')

Kept getting in another script so I made this test script to see what the problem was:

import  os, asyncio
from  arsenic  import  browsers, services, get_session

os.chdir(os.path.dirname(__file__))
chromeDriverPath  =  "./chromedriver"

async  def  GoToGoogle():
    service  =  services.Chromedriver(binary=chromeDriverPath)
    browser  =  browsers.Chrome()
    async  with  get_session(service, browser) as  session:
    await  session.get("www.google.com")
    await  asyncio.sleep(1000)

  asyncio.run(GoToGoogle())

The browser is able to open, but when session.get() is called, it instantly crashes. The chromedriver version is 98.0.4758.80, and the google chrome version is the same. The equivalent of this script is working in Selenium. If this isn't a bug and my new-to-async and arsenic brain has got the code wrong, please tell me what I've gotten wrong.

AstroTheRabbit commented 2 years ago

Not a bug, I think I got the URL wrong as it is working fine now.