Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#58 is a dynamic-sized tensor). #158

Open
teejc opened this issue Nov 6, 2024 · 4 comments

Comments

@teejc
Copy link

teejc commented Nov 6, 2024

Hi i've got this error when running send_direct_message(num, msg):

DevTools listening on ws://127.0.0.1:60399/devtools/browser/037eb95b-29d7-49bd-8a2b-5e09cb051e6f
Created TensorFlow Lite XNNPACK delegate for CPU.
Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#58 is a dynamic-sized tensor).
Traceback (most recent call last):
File "D:\Project\Python\whatsapp_alright.py", line 3, in
messenger.send_direct_message("60163827163", 'Hello')
File "C:\Users\Tee\AppData\Roaming\Python\Python312\site-packages\alright_init_.py", line 486, in send_direct_message
self.find_by_username(mobile)
File "C:\Users\Tee\AppData\Roaming\Python\Python312\site-packages\alright_init_.py", line 158, in find_by_username
search_box = self.wait.until(
^^^^^^^^^^^^^^^^
File "C:\Users\Tee\AppData\Roaming\Python\Python312\site-packages\selenium\webdriver\support\wait.py", line 105, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
GetHandleVerifier [0x00F83913+24035]
(No symbol) [0x00F0BCA4]
(No symbol) [0x00DEC2D3]
(No symbol) [0x00E2DC86]
(No symbol) [0x00E2DECB]
(No symbol) [0x00E6B9D2]
(No symbol) [0x00E4FED4]
(No symbol) [0x00E6953F]
(No symbol) [0x00E4FC26]
(No symbol) [0x00E2218C]
(No symbol) [0x00E2310D]
GetHandleVerifier [0x01229743+2800659]
GetHandleVerifier [0x012842FE+3172302]
GetHandleVerifier [0x0127CF12+3142626]
GetHandleVerifier [0x01026CC0+692624]
(No symbol) [0x00F14CBD]
(No symbol) [0x00F119C8]
(No symbol) [0x00F11B60]
(No symbol) [0x00F04010]
BaseThreadInitThunk [0x76F27BA9+25]
RtlInitializeExceptionChain [0x77C7C0CB+107]
RtlClearBits [0x77C7C04F+191]

The web whatsapp does not find contact and send the message.

May i know what's the cause of this?

@Ali-A-Yousefi
Copy link

Ali-A-Yousefi commented Nov 6, 2024

Hi @teejc , this might be related to your issue:
i was getting the same error:
Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#58 is a dynamic-sized tensor)

for
messenger.send_message(message)

to fix it i went to "venv\Lib\site-packages\alright_init_.py"
then updated the path to the message bar/box:
under:
def send_message(self, message, timeout=0.0):
old:
inp_xpath = '//*[@id="main"]/footer/div/div/span[2]/div/div[2]/div/div/div'
new:
inp_xpath = '//*[@id="main"]/footer/div[1]/div/span/div/div[2]/div[1]/div/div[1]'

So you will probably have to do the same with all the paths that you will use, get the new XPATH and update it for each element.

this may fix it for you.

@teejc
Copy link
Author

teejc commented Nov 6, 2024

Hi @teejc , this might be related to your issue: i was getting the same error: Attempting to use a delegate that only supports static-sized tensors with a graph that has dynamic-sized tensors (tensor#58 is a dynamic-sized tensor)

for messenger.send_message(message)

to fix it i went to "venv\Lib\site-packages\alright__init__.py" then updated the path to the message bar/box: under: def send_message(self, message, timeout=0.0): old: inp_xpath = '//*[@id="main"]/footer/div/div/span[2]/div/div[2]/div/div/div' new: inp_xpath = '//*[@id="main"]/footer/div[1]/div/span/div/div[2]/div[1]/div/div[1]'

So you will probably have to do the same with all the paths that you will use, get the new XPATH and update it for each element.

this may fix it for you.

Thanks for the tips!

Using your solution I manage to get it works with send_message1(num, msg), but still got the same error using send_direct_message() or send_message().

@Ali-A-Yousefi
Copy link

Ali-A-Yousefi commented Nov 7, 2024

@teejc
You will need to find the XPATH for each method you want to use. This is done by going into WhatsApp and inspecting the components that are used by the used method and taking their XPATH.

Example:
find_by_username


def find_by_username(self, username):
      """find_user_by_name ()

      locate existing contact by username or number

      Args:
          username ([type]): [description]
      """
      search_box = self.wait.until(
          EC.presence_of_element_located(
              (
                  By.XPATH,
                   "/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]",
              )
          )
      )
....

i saw that is was searching for 'search_box'

so i want into WhatsApp web, inspected the search_box and copied the XPATH for the box :
'//*[@id="side"]/div[1]/div/div[2]/div[2]/div/div'

so i just replaced it without making a new method:


def find_by_username(self, username):
    """find_user_by_name ()

    locate existing contact by username or number

    Args:
        username ([type]): [description]
    """
    search_box = self.wait.until(
        EC.presence_of_element_located(
            (
                By.XPATH,
                # "/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]",
                '//*[@id="side"]/div[1]/div/div[2]/div[2]/div/div',
            )
        )
    )

this way i call messenger.find_by_username('name") directly

After checking send_direct_message:
it is :


def send_direct_message(self, mobile: str, message: str, saved: bool = True):
    if saved:
        self.find_by_username(mobile)
    else:
        self.find_user(mobile)
    self.send_message(message)


so you will need to update All XPATHs inside: find_by_username (if you have the person saved with a name), send_message

@teejc
Copy link
Author

teejc commented Nov 8, 2024

@teejc You will need to find the XPATH for each method you want to use. This is done by going into WhatsApp and inspecting the components that are used by the used method and taking their XPATH.

Example: find_by_username


def find_by_username(self, username):
      """find_user_by_name ()

      locate existing contact by username or number

      Args:
          username ([type]): [description]
      """
      search_box = self.wait.until(
          EC.presence_of_element_located(
              (
                  By.XPATH,
                   "/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]",
              )
          )
      )
....

i saw that is was searching for 'search_box'

so i want into WhatsApp web, inspected the search_box and copied the XPATH for the box : '//*[@id="side"]/div[1]/div/div[2]/div[2]/div/div'

so i just replaced it without making a new method:


def find_by_username(self, username):
    """find_user_by_name ()

    locate existing contact by username or number

    Args:
        username ([type]): [description]
    """
    search_box = self.wait.until(
        EC.presence_of_element_located(
            (
                By.XPATH,
                # "/html/body/div[1]/div/div/div[4]/div/div[1]/div/div/div[2]/div/div[1]",
                '//*[@id="side"]/div[1]/div/div[2]/div[2]/div/div',
            )
        )
    )

this way i call messenger.find_by_username('name") directly

After checking send_direct_message: it is :


def send_direct_message(self, mobile: str, message: str, saved: bool = True):
    if saved:
        self.find_by_username(mobile)
    else:
        self.find_user(mobile)
    self.send_message(message)

so you will need to update All XPATHs inside: find_by_username (if you have the person saved with a name), send_message

Much appreciated for your help, it did works.

However i found another strange behaviour when i loop through send_direct_message() to send multiple message to multiple user. The last message will always not sent out.

from alright import WhatsApp
messenger = WhatsApp()
mobNum = [num1, num2, num3]
messages = [msg1, msg2, msg3]
for num, msg in zip(mobNum, messages):
messenger.send_direct_message(num, msg, False)

As a solution i went to "venv\Lib\site-packages\alright_init_.py" and add another line of

input_box.send_keys(Keys.ENTER)

below the existing line then it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants