shauryauppal / PyWhatsapp

Python Automation using selenium & Scheduling of messages and media
https://www.linkedin.com/in/shaurya-uppal
Apache License 2.0
455 stars 159 forks source link

linux pyautoit replace #64

Closed lalamax3d closed 3 years ago

lalamax3d commented 4 years ago

Hi, thanks for amazing tool. on linux, pyautoit doesn't work, ( i am on ubuntu 20, atleast for me ). i tried searching for replacement. it seems its needed while attaching file open dialog >> giving file_path >> hitting OK button etc.

Q. is pyautoit only for windows based solution? or works with linux as well? to control dialogs with mouse etc? Q. is there a fix / solution? huge thanks. Q. can autopy OR pyautogui be used instead of this.?

shauryauppal commented 3 years ago

You found any replacement?

lalamax3d commented 3 years ago

no. i wasn't able to confirm which one from above possibly can work and also wasn't able to find some other solution.

jrom99 commented 3 years ago

I could avoid PyAutoIt in Ubuntu 20.10 by making the following amendments, it uses the <input> tag inside the <button>:

# About 6 seconds
def _send_image(filename: str):
    """Function to send Images (jpg, png)

    Args:
        filename (str): Image full filepath.
    """
    # Attachment Drop Down Menu
    clipButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]/footer//*[@data-icon="clip"]/..')))
    clipButton.click()

    # To send an Image
    imgButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]/footer//*[@data-icon="attach-image"]/../input')))
    imgButton.send_keys(filename)

    sendButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@data-icon="send"]')))
    sendButton.click()

    # Waiting for the pending clock icon to disappear
    wait.until_not(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]//*[@data-icon="msg-time"]')))

# About 6 seconds
def _send_file(filename: str):
    """Function to send Documents (PDF, Word file, PPT, etc.)

    Args:
        filename (str): Document full filepath.
    """
    # Attachment Drop Down Menu
    clipButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]/footer//*[@data-icon="clip"]/..')))
    clipButton.click()

    # To send a Document(PDF, Word file, PPT)
    docButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]/footer//*[@data-icon="attach-document"]/../input')))
    docButton.send_keys(filename)

    sendButton = wait.until(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@data-icon="send"]')))
    sendButton.click()

    # Waiting for the pending clock icon to disappear
    wait.until_not(EC.presence_of_element_located(
        (By.XPATH,
        '//*[@id="main"]//*[@data-icon="msg-time"]')))
lalamax3d commented 3 years ago

@jrom99 , thanks, I'll test it over weekend and close the issue. huge thanks again.

lalamax3d commented 3 years ago

just wanted to say, thanks again, for help, issue sorted @jrom99 . have a good day