Tithibots/tithiwa

Make clear_chats_of_all_groups() to clear chats of all whatsapp groups.

NavpreetDevpuri opened this issue · 2 comments

Automate as follow or try something else

  1. go through all chats by using the DOWN arrow key because in HTML all chats are un-ordered
  2. determine someway that the currently active element on the browser is a group. browser.switch_to.active_element
  3. then if its a group then just automate Clear messages for that group
    ShareX_bge3iVVLh8

tithiwa/tithiwa/group.py

Lines 113 to 130 in 7cef0e1

def exit_from_all_groups(self):
self._wait_for_an_presence_of_element(SELECTORS.GROUPS.GROUP_NAME_IN_CHATS)
self._wait_for_an_element_to_be_clickable(SELECTORS.MAIN_SEARCH_BAR).click()
preactive = None
self.browser.switch_to.active_element.send_keys(Keys.ARROW_DOWN)
curractive = self.browser.switch_to.active_element
while curractive != preactive:
groupnameelement = None
try:
groupnameelement = curractive.find_element(By.CSS_SELECTOR, SELECTORS.GROUPS.GROUP_NAME_IN_CHATS)
except:
pass
if groupnameelement != None:
groupname = groupnameelement.get_attribute('innerText')
self._wait_for_group_to_open_then_exit(groupname)
preactive = curractive
curractive.send_keys(Keys.ARROW_DOWN)
curractive = self.browser.switch_to.active_element

That's how we can go through all chats

  1. go through all group chats same as in exit_from_all_groups()
  2. open group options using CHATROOM__OPTIONS
  3. press on Clear chat and wait for the chat to be cleared by using self._close_info()