Skip to content

Commit

Permalink
Fixing appropriately the "Sending videos" wait issue
Browse files Browse the repository at this point in the history
@theCJMan pointed out that sending vids (in multiple contact loop) is to fast and then vids is not sent. We're adding a wait in each video "send_attachment" - in fact, it could be an issue with any large attachment. Tested this with 14MB video and multiple contacts, and it works nicely. 

For all contributors: please, make sure you're developing on the most recent version of the main repo!
  • Loading branch information
euriconicacio authored Jun 17, 2022
1 parent 005a12a commit 716080d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions alright/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ def find_attachment(self):
clipButton.click()

def send_attachment(self):

# Waiting for the pending clock icon to disappear
self.wait.until_not(
EC.presence_of_element_located(
Expand All @@ -399,6 +400,14 @@ def send_attachment(self):
)
sendButton.click()

# Waiting for the pending clock icon to disappear again - workaround for large files or loading videos.
# Appropriate solution for the presented issue. [nCKbr]
self.wait.until_not(
EC.presence_of_element_located(
(By.XPATH, '//*[@id="main"]//*[@data-icon="msg-time"]')
)
)

def send_picture(self, picture, message):
"""send_picture ()
Expand Down Expand Up @@ -460,9 +469,9 @@ def send_video(self, video):
CJM - 2022/06/10: Only if file is less than 14MB (WhatsApp limit is 15MB)
Args:
video ([type]): [description]
video ([type]): the video file to be sent.
"""

import pdb; pdb.set_trace()
try:
filename = os.path.realpath(video)
f_size = os.path.getsize(filename)
Expand All @@ -481,6 +490,7 @@ def send_video(self, video):
)

video_button.send_keys(filename)

self.send_attachment()
LOGGER.info(f"Video has been successfully sent to {self.mobile}")
else:
Expand Down

0 comments on commit 716080d

Please sign in to comment.