Skip to content

Commit

Permalink
Completed #33 and linted
Browse files Browse the repository at this point in the history
  • Loading branch information
thelabcat committed Nov 8, 2024
1 parent c0eac82 commit c9000d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/rumchat_actor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,13 @@ def __send_message(self, text):
self.sent_messages.append(text)
self.last_message_send_time = time.time()
self.driver.find_element(By.ID, "chat-message-text-input").send_keys(text)
self.driver.find_element(By.CLASS_NAME, "chat--send").click()
send_bttn = self.driver.find_element(By.CLASS_NAME, "chat--send")
#Wait for message to be sendable
start_time = time.time()
while (disabled := send_bttn.get_attribute("disabled") is not None) and time.time() - start_time < static.Message.sendable_check_timeout:
time.sleep(static.Message.sendable_check_interval)
assert not disabled, "Message send button never enabled"
send_bttn.click()

def hover_element(self, element):
"""Hover over a selenium element"""
Expand Down
1 change: 0 additions & 1 deletion src/rumchat_actor/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.select import Select
from . import static, utils

class ClipUploader():
Expand Down
6 changes: 6 additions & 0 deletions src/rumchat_actor/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class Message:
#Prefix to all actor messages
bot_prefix = "🤖: "

#How long to wait between checking if the send button is enabled
sendable_check_interval = 0.01

#How long to wait for the send button to enable
sendable_check_timeout = 1

#How long to wait between sending messages
send_cooldown = 3

Expand Down

0 comments on commit c9000d1

Please sign in to comment.