Tithibots / tithiwa

Automate Web WhatsApp with selenium in python.
MIT License
24 stars 22 forks source link

Handle same name groups while exiting groups #50

Closed NavpreetDevpuri closed 3 years ago

NavpreetDevpuri commented 3 years ago

If we have the same name groups as follows.

from tithiwa import Tithiwa

tithiwabot = Tithiwa()
tithiwabot.open_session()
tithiwabot.create_group("Group made by tithiwa", ["Navpreet Devpuri"])
tithiwabot.create_group("Group made by tithiwa", ["Navpreet Devpuri"])
tithiwabot.create_group("Group made by tithiwa", ["Navpreet Devpuri"])
tithiwabot.exit_from_all_groups()

chrome_HkwKk6HfTD

Then it fails to exit from the 2nd and 3rd group because

  1. when we try to open the 2nd group after the 1st group it waits for the group to be opened before exiting it.
  2. it waits for the group name to appear on the chatroom
  3. But the 1st group already has the same group name
  4. So it just doesn't wait for the 2nd group to be opened
  5. it thinks like Yes we already exited that group and goes to the next one.

that's how it is skipping the same name groups. https://github.com/Tithibots/tithiwa/blob/654e4f4ef008963b0665bd3652bcf3679b0ce202/tithiwa/group.py#L127 https://github.com/Tithibots/tithiwa/blob/654e4f4ef008963b0665bd3652bcf3679b0ce202/tithiwa/group.py#L161-L164 https://github.com/Tithibots/tithiwa/blob/654e4f4ef008963b0665bd3652bcf3679b0ce202/tithiwa/waobject.py#L109-L118

NavpreetDevpuri commented 3 years ago

HINT: Save the previous group name HTML element in a new variable then use _wait_for_an_element_to_deattached() to wait for it to disappear then check for the next group name.

DEBUGGING helps a lot. w2iwBUVdly

NavpreetDevpuri commented 3 years ago

That's how we can navigate to the details of the codebase to understand something By pressing CTRL + Left mouse button SEUi2zOGwo

NavpreetDevpuri commented 3 years ago

That's how the browser's Inspect elements and console helps gsfSeY6fQA