alexal1 / Insomniac

Instagram bot for automated Instagram interaction using Android device via ADB
https://insomniac-bot.com
MIT License
688 stars 159 forks source link

Error - -32001 Jsonrpc error: UI Object not Found exception #436

Open yurimlima opened 2 years ago

yurimlima commented 2 years ago

Hey guys, this error is coming up eventually and I can't understand why or fix it. It works and interact with users normally, but, from time to time I get crashes and exceptions as logged below:

[06/14 18:02:27] Back to profiles list
[06/14 18:02:30] Next item not found: probably reached end of the screen.
[06/14 18:02:37] Cannot find the list of followers. Trying to press back again.
[06/14 18:02:38] Need to scroll now
[06/14 18:02:49] Error - -32001 Jsonrpc error: <android.support.test.uiautomator.UiObjectNotFoundException> data: UiSelector[CLASS=android.widget.ListView, RESOURCE_ID=android:id/list], method: scrollToEnd

Looking for ADB devices...
Connected devices via adb: 1. That's ok.
[06/14 18:02:50] Could not save crash after an error. Crash-save-error: format_exception() got an unexpected keyword argument 'etype'Traceback (most recent call last):
  File "C:\Users\xx\Desktop\Scripts\insomniac\device_facade.py", line 528, in scroll
    self.viewV2.scroll.toEnd(max_swipes=1)
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\uiautomator2\session.py", line 1196, in __call__     
    return jsonrpc.scrollToEnd(selector, self.vertical,
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\uiautomator2\__init__.py", line 546, in __call__     
    return self.server.jsonrpc_retry_call(self.method, params,
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\uiautomator2\__init__.py", line 553, in jsonrpc_retry_call
    return self.jsonrpc_call(*args, **kwargs)
  File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\uiautomator2\__init__.py", line 645, in jsonrpc_call 
    raise err
uiautomator2.exceptions.UiObjectNotFoundError: -32001 Jsonrpc error: <android.support.test.uiautomator.UiObjectNotFoundException> data: UiSelector[CLASS=android.widget.ListView, RESOURCE_ID=android:id/list], method: scrollToEnd

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xx\Desktop\Scripts\insomniac\safely_runner.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\xx\Desktop\Scripts\insomniac\action_runners\interact\__init__.py", line 150, in job
    handle_blogger(device_wrapper.get(),
  File "C:\Users\xx\Desktop\Scripts\insomniac\action_runners\interact\action_handle_blogger.py", line 240, in handle_blogger       
    followers_following_list_view.iterate_over_followers(is_myself, interact_with_follower, pre_conditions)
  File "C:\Users\xx\Desktop\Scripts\insomniac\views.py", line 1461, in iterate_over_followers
    list_view.scroll(DeviceFacade.Direction.BOTTOM)
  File "C:\Users\xx\Desktop\Scripts\insomniac\device_facade.py", line 530, in scroll
    raise DeviceFacade.JsonRpcError(e)
insomniac.device_facade.DeviceFacade.JsonRpcError: -32001 Jsonrpc error: <android.support.test.uiautomator.UiObjectNotFoundException> data: UiSelector[CLASS=android.widget.ListView, RESOURCE_ID=android:id/list], method: scrollToEnd

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xx\Desktop\Scripts\insomniac\utils.py", line 221, in save_crash
    outfile.write(describe_exception(ex))
  File "C:\Users\xx\Desktop\Scripts\insomniac\utils.py", line 372, in describe_exception
    trace = ''.join(traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__)) if with_stacktrace else ''
TypeError: format_exception() got an unexpected keyword argument 'etype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xx\Desktop\Scripts\insomniac\session.py", line 318, in run
    action_runner.run(device_wrapper,
  File "C:\Users\xx\Desktop\Scripts\insomniac\action_runners\interact\__init__.py", line 202, in run
    job()
  File "C:\Users\xx\Desktop\Scripts\insomniac\safely_runner.py", line 32, in wrapper
    save_crash(device_wrapper.get(), ex)
  File "C:\Users\xx\Desktop\Scripts\insomniac\utils.py", line 232, in save_crash
    print(COLOR_FAIL + describe_exception(e) + COLOR_ENDC)
  File "C:\Users\xx\Desktop\Scripts\insomniac\utils.py", line 372, in describe_exception
    trace = ''.join(traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__)) if with_stacktrace else ''
TypeError: format_exception() got an unexpected keyword argument 'etype'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\xx\Desktop\Scripts\start.py", line 4, in <module>
    insomniac.run(activation_code)
  File "C:\Users\xx\Desktop\Scripts\insomniac\__init__.py", line 33, in run
    insomniac_session.run()
  File "C:\Users\xx\Desktop\Scripts\insomniac\session.py", line 343, in run
    print(COLOR_FAIL + describe_exception(ex) + COLOR_ENDC)
  File "C:\Users\xx\Desktop\Scripts\insomniac\utils.py", line 372, in describe_exception
    trace = ''.join(traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__)) if with_stacktrace else ''
TypeError: format_exception() got an unexpected keyword argument 'etype'

I'm using the supported IG Version and the updated insomniac release (3.8.2). Any ideas?

jansvanda commented 2 years ago

I got the same error

Traceback (most recent call last): File "C:\Users\svand\Downloads\Insomniac-master\start.py", line 4, in <module> insomniac.run(activation_code) File "C:\Users\svand\Downloads\Insomniac-master\insomniac\__init__.py", line 33, in run insomniac_session.run() File "C:\Users\svand\Downloads\Insomniac-master\insomniac\session.py", line 343, in run print(COLOR_FAIL + describe_exception(ex) + COLOR_ENDC) File "C:\Users\svand\Downloads\Insomniac-master\insomniac\utils.py", line 372, in describe_exception trace = ''.join(traceback.format_exception(etype=type(ex), value=ex, tb=ex.__traceback__)) if with_stacktrace else '' TypeError: format_exception() got an unexpected keyword argument 'etype'

@alexal1 any ideas?

jansvanda commented 2 years ago

removing etype=type(ex), from utils.py/372 HELPED :) def describe_exception(ex, with_stacktrace=True, context=None): exception_context = f'({context}): ' if context is not None else '' trace = ''.join(traceback.format_exception(value=ex, tb=ex.__traceback__)) if with_stacktrace else '' description = f"{exception_context}Error - {str(ex)}\n{trace}" return description

skiwlkr commented 2 years ago

I tried removing the etype=type(ex) but I think I might have a different error.

Error - module 'uiautomator2' has no attribute 'JsonRpcError'


`[07/07 22:22:00] Choosing a random post from those on the screen
[07/07 22:22:30] Error - module 'uiautomator2' has no attribute 'JsonRpcError'
Traceback (most recent call last):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\device_facade.py", line 591, in get_bounds
    return self.viewV2.info['bounds']
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\retry\api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\retry\api.py", line 33, in __retry_internal
    return f()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\_selector.py", line 130, in info
    return self.jsonrpc.objInfo(self.selector)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 475, in __call__
    return self.server._jsonrpc_retry_call(self.method, params,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 482, in _jsonrpc_retry_call
    return self._jsonrpc_call(*args, **kwargs)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 551, in _jsonrpc_call
    raise err
uiautomator2.exceptions.UiObjectNotFoundError: -32001 Jsonrpc error: <androidx.test.uiautomator.UiObjectNotFoundException> data: UiSelector[CHILD=UiSelector[INSTANCE=16, CLASS_REGEX=android.widget.ImageView|android.widget.Button, RESOURCE_ID=com.instagram.android:id/image_button], CLASS_REGEX=androidx.recyclerview.widget.RecyclerView|android.view.View, RESOURCE_ID=com.instagram.android:id/recycler_view], method: objInfo

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\session.py", line 318, in run
    action_runner.run(device_wrapper,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\__init__.py", line 202, in run
    job()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\safely_runner.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\__init__.py", line 167, in job
    handle_hashtag(device_wrapper.get(),
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\action_handle_hashtag.py", line 285, in handle_hashtag
    interact_with_feed(navigate_to_feed, should_continue_interact_with_feed, interact_with_feed_post)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\actions_impl.py", line 859, in interact_with_feed
    posts_views_list = navigate_to_feed()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\action_handle_hashtag.py", line 233, in navigate_to_feed
    posts_view_list = PostsGridView(device).open_random_post()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\views.py", line 944, in open_random_post
    if not ActionBarView.is_in_interaction_rect(post_view):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\views.py", line 309, in is_in_interaction_rect
    view_top = view.get_bounds()['top']
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\device_facade.py", line 592, in get_bounds
    except uiautomator2.JsonRpcError as e:
AttributeError: module 'uiautomator2' has no attribute 'JsonRpcError'

Error - module 'uiautomator2' has no attribute 'JsonRpcError'
Traceback (most recent call last):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\device_facade.py", line 591, in get_bounds
    return self.viewV2.info['bounds']
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\retry\api.py", line 73, in retry_decorator
    return __retry_internal(partial(f, *args, **kwargs), exceptions, tries, delay, max_delay, backoff, jitter,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\retry\api.py", line 33, in __retry_internal
    return f()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\_selector.py", line 130, in info
    return self.jsonrpc.objInfo(self.selector)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 475, in __call__
    return self.server._jsonrpc_retry_call(self.method, params,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 482, in _jsonrpc_retry_call
    return self._jsonrpc_call(*args, **kwargs)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\uiautomator2\__init__.py", line 551, in _jsonrpc_call
    raise err
uiautomator2.exceptions.UiObjectNotFoundError: -32001 Jsonrpc error: <androidx.test.uiautomator.UiObjectNotFoundException> data: UiSelector[CHILD=UiSelector[INSTANCE=16, CLASS_REGEX=android.widget.ImageView|android.widget.Button, RESOURCE_ID=com.instagram.android:id/image_button], CLASS_REGEX=androidx.recyclerview.widget.RecyclerView|android.view.View, RESOURCE_ID=com.instagram.android:id/recycler_view], method: objInfo

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\session.py", line 318, in run
    action_runner.run(device_wrapper,
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\__init__.py", line 202, in run
    job()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\safely_runner.py", line 24, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\__init__.py", line 167, in job
    handle_hashtag(device_wrapper.get(),
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\action_handle_hashtag.py", line 285, in handle_hashtag
    interact_with_feed(navigate_to_feed, should_continue_interact_with_feed, interact_with_feed_post)
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\actions_impl.py", line 859, in interact_with_feed
    posts_views_list = navigate_to_feed()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\action_runners\interact\action_handle_hashtag.py", line 233, in navigate_to_feed
    posts_view_list = PostsGridView(device).open_random_post()
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\views.py", line 944, in open_random_post
    if not ActionBarView.is_in_interaction_rect(post_view):
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\views.py", line 309, in is_in_interaction_rect
    view_top = view.get_bounds()['top']
  File "C:\Users\wayne\AppData\Local\Programs\Python\Python38\lib\site-packages\insomniac\device_facade.py", line 592, in get_bounds
    except uiautomator2.JsonRpcError as e:
AttributeError: module 'uiautomator2' has no attribute 'JsonRpcError'
`
6FaNcY9 commented 2 years ago

same