diff --git a/.gitignore b/.gitignore index 8c54ada..d536845 100644 --- a/.gitignore +++ b/.gitignore @@ -143,3 +143,7 @@ dmypy.json # Pyre type checker .pyre/ + +# IDE folders +.idea/ +.vs/ diff --git a/requirements.txt b/requirements.txt index fafd699..7cb6656 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ selenium -phonenumbers diff --git a/whatsapp_api.py b/whatsapp_api.py index f0b8acb..ec131bb 100644 --- a/whatsapp_api.py +++ b/whatsapp_api.py @@ -1,18 +1,28 @@ from selenium import webdriver from selenium.webdriver.chrome.options import Options +from selenium.webdriver import ActionChains from time import sleep +import sys # Parameters WP_LINK = 'https://web.whatsapp.com' -## XPATHS +# XPATHS CONTACTS = '//*[@id="main"]/header/div[2]/div[2]/span' SEND = '//*[@id="main"]/footer/div[1]/div[3]' MESSAGE_BOX = '//*[@id="main"]/footer/div[1]/div[2]/div/div[2]' NEW_CHAT = '//*[@id="side"]/header/div[2]/div/span/div[2]/div' SEARCH_CONTACT = '//*[@id="app"]/div/div/div[2]/div[1]/span/div/span/div/div[1]/div/label/input' FIRST_CONTACT = '//*[@id="app"]/div/div/div[2]/div[1]/span/div/span/div/div[2]/div/div/div/div[2]/div' +MoreContactsXPath = '//*[@id="app"]/div/div/div[2]/div[3]/span/div/span/div/div/div[1]/div[5]/div[5]/div[2]' +GroupInfoXPath = '// *[ @ id = "app"] / div / div / div[2] / div[3] / span / div / span / div / div / div[1]' +# Classes +nameClass = '_19RFN._1ovWX._F7Vk' +messageClass = '_12pGw' +messageMenuClass = '_2-qoA' +messageMenuButtonsClass = '_3zy-4.Sl-9e._3_4Kp' +eraseButtonsClass = '_2eK7W._23_1v' class WhatsApp: def __init__(self): @@ -33,13 +43,13 @@ def _get_element(self, xpath, attempts=5, _count=0): '''Safe get_element method with multiple attempts''' try: element = self.driver.find_element_by_xpath(xpath) - print('Found element!') + # print('Found element!') return element except Exception as e: - if _count