Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link preview #25

Open
amelsakka opened this issue Sep 8, 2021 · 2 comments
Open

Link preview #25

amelsakka opened this issue Sep 8, 2021 · 2 comments

Comments

@amelsakka
Copy link

Sorry, I'm developing for fun and I don't know much about github, so please forgive my ignorance.

I have an idea to be added to alright (nice job, by the way @Kalebu ):

A function to send a link with link preview.

First I added another wait in init:
self.wait2 = WebDriverWait(self.browser, 5)

Then the new function:

    def send_link(self, message):
        try:
            inp_xpath = '//*[@id="main"]/footer/div[1]/div[2]/div/div[1]/div/div[2]'
            lnk_xpath = '//*[@id="main"]/footer/div[2]/div[1]/div[5]/div[1]/div[1]'
            input_box = self.wait.until(
                EC.presence_of_element_located((By.XPATH, inp_xpath)))
            input_box.send_keys(message + Keys.SPACE)
            try:
                input_box2 = self.wait2.until(
                    EC.presence_of_element_located((By.XPATH, lnk_xpath)))
            except: 
                pass
            input_box.send_keys(" " + Keys.ENTER)
            print(f"Message with link sent successfuly to {self.mobile}")
        except (NoSuchElementException, Exception) as bug:
            print(bug)
            print(f'Failed to send a message with link to {self.mobile}')

        finally:
            print("send_link() finished running ")

It waits for 5 seconds for the preview to load, if it didn't load, then it sends the message anyway without preview.

@vadolasi
Copy link
Contributor

vadolasi commented Sep 9, 2021

Create a pull request to add your function.
See https://opensource.com/article/19/7/create-pull-request-github to learn how

@Kalebu
Copy link
Owner

Kalebu commented Sep 9, 2021

Hello @amelsakka, You're warmly welcomed to the team of alright contributors.

Hope that the link shared by @vadolasi will help you figure out on making your feature added to alright.

Let us know if you will face any issues in the process of making your contribution.

Wish you the best of luck

Best regards
Kalebu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants