devwithkunal / whatsapp-bulk-messenger

Send bulk messages on whatsapp.
MIT License
13 stars 11 forks source link

error #4

Open rockstar3504 opened 1 year ago

rockstar3504 commented 1 year ago

It's not working in my Google Chrome here is error code..

PS D:\whatsapp-bulk-messenger-experimental> & "C:/Program Files/Python311/python.exe" d:/whatsapp-bulk-messenger-experimental/main_2.py

DevTools listening on ws://127.0.0.1:65186/devtools/browser/4e025f0d-34cb-465a-8467-acdf308d8602 Traceback (most recent call last): File "d:\whatsapp-bulk-messenger-experimental\main_2.py", line 42, in msg_input = driver.find_element(By.CSS_SELECTOR, '._1CGek input') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dilip\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\remote\webdriver.py", line 739, in find_element return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\dilip\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute self.error_handler.check_response(response) File "C:\Users\dilip\AppData\Roaming\Python\Python311\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"._1CGek input"} (Session info: chrome=117.0.5938.63); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception Stacktrace: GetHandleVerifier [0x003BCE43+45171] (No symbol) [0x00349091] (No symbol) [0x0023BE1D] (No symbol) [0x0026ED40] (No symbol) [0x0026F20B] (No symbol) [0x0029F692] (No symbol) [0x0028B094] (No symbol) [0x0029DCFA] (No symbol) [0x0028AE46] (No symbol) [0x0026675E] (No symbol) [0x002678FD] GetHandleVerifier [0x00675449+2897529] GetHandleVerifier [0x006BDBFB+3194411] GetHandleVerifier [0x006B79D1+3169281] GetHandleVerifier [0x004460C0+606960] (No symbol) [0x00352E0C] (No symbol) [0x0034EF98] (No symbol) [0x0034F0BF] (No symbol) [0x003417B7] BaseThreadInitThunk [0x75027BA9+25] RtlInitializeExceptionChain [0x770FB79B+107] RtlClearBits [0x770FB71F+191]

devwithkunal commented 1 year ago

Two possible reasons for the error:

  1. The page has not loaded properly.
  2. You need to update the WhatsApp web.

To solve the first error increase the time variables.

rockstar3504 commented 1 year ago

No, I have increased the time still not working after login It disappears.

VimaleshCT commented 2 weeks ago

DevTools listening on ws://127.0.0.1:55392/devtools/browser/bb466553-69fc-4e66-8b97-14ba21937e52 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).

Packages

from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.by import By import time

Config

login_time = 30 # Time for login (in seconds) new_msg_time = 5 # TTime for a new message (in seconds) send_msg_time = 5 # Time for sending a message (in seconds) country_code = 91 # Set your country code action_time = 2 # Set time for button click action

Absolute path to you image

Create driver

driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))

Encode Message Text

Encode Message Text with error handling

with open('message.txt', 'r', encoding='utf-8', errors='replace') as file: msg = file.read()

Loop Through Numbers List

with open('numbers.txt', 'r', encoding='utf-8') as file: for n in file.readlines(): num = n.rstrip() link = f'https://web.whatsapp.com/send/?phone={country_code}{num}' driver.get(link) time.sleep(new_msg_time)

    # Start the action chain to write the message
    actions = ActionChains(driver)
    for line in msg.split('\n'):
        actions.send_keys(line)
        # SHIFT + ENTER to create next line
        actions.key_down(Keys.SHIFT).send_keys(Keys.ENTER).key_up(Keys.SHIFT)
    actions.send_keys(Keys.ENTER)
    actions.perform()
    time.sleep(send_msg_time)

Quit the driver

driver.quit()

i am getting this error.. help me to solve this